Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!y34g2000prb.googlegroups.com!not-for-mail
From: jrenfree <jrenfree@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Normalizing a PDF
Date: Wed, 25 Mar 2009 09:25:42 -0700 (PDT)
Organization: http://groups.google.com
Lines: 46
Message-ID: <ab57211a-90f6-4758-b334-1b95f04ed3e1@y34g2000prb.googlegroups.com>
NNTP-Posting-Host: 137.110.142.168
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1237998342 24906 127.0.0.1 (25 Mar 2009 16:25:42 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 25 Mar 2009 16:25:42 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: y34g2000prb.googlegroups.com; posting-host=137.110.142.168; 
	posting-account=lVpOYAoAAAD2lyD71kM3JZW0H08VNtYu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) 
	AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.48 Safari/525.19,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:527657

Hi all,

What's the best way to normalize a PDF?  Here's an example of some
code for a PDF that I'm trying to normalize:

****************************************
function [Wr,x] = getPDF
e = 0.01;
b = linspace(.005,1,1e4);
x = e./b;    % Values to evaluate for PDF

% Define PDF function parameters
gamma = 4;
sigma = 1e-4;

Wr = riceanpdf(x,gamma,sigma);     % get PDF

trapz(x,Wr)

function Wr = riceanpdf(e,gamma,sigma)
%% Ricean pdf

q = 2.*e.*sqrt(gamma.*(1+gamma))./sqrt(sigma);

term1 = 2.*e.*(1+gamma)./sigma;
term2 = exp(-1.*((1+gamma).*e.^2+gamma.*sigma)./sigma);
term3 = besseli(0,q);

Wr = term1.*term2.*term3;

Wr(isnan(Wr)) = 0;
**********************************************

When I do trapz(x,Wr), which should be the numerical integration, I'm
getting a value of -.4351 (which I'm not even sure is possible since
Wr has no negative values).  How would I normalize this PDF so that
the integration of it, or trapz(x,Wr), is 1?

I've done it for other PDFs by doing something like:

newWr = length(x).*Wr./(sum(Wr).*max(x));

But that doesn't work in this case since the spacing in the x-vector
are not constant.

Thanks!