From: jrenfree <>
Newsgroups: comp.soft-sys.matlab
Subject: Normalizing a PDF
Date: Wed, 25 Mar 2009 09:25:42 -0700 (PDT)
Lines: 46
Message-ID: <>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: 1237998342 24906 (25 Mar 2009 16:25:42 GMT)
NNTP-Posting-Date: Wed, 25 Mar 2009 16:25:42 +0000 (UTC)
Injection-Info:; posting-host=; 
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/ Safari/525.19,gzip(gfe),gzip(gfe)
Xref: 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


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.