On Mar 25, 9:59=A0am, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> jrenfree <jrenf...@gmail.com> wrote in message <ab57211a90f64758b3341=
b95f04ed...@y34g2000prb.googlegroups.com>...
> > Hi all,
>
> > What's the best way to normalize a PDF? =A0Here's an example of some
> > code for a PDF that I'm trying to normalize:
>
> > ****************************************
> > function [Wr,x] =3D getPDF
> > e =3D 0.01;
> > b =3D linspace(.005,1,1e4);
> > x =3D e./b; =A0 =A0% Values to evaluate for PDF
>
> > % Define PDF function parameters
> > gamma =3D 4;
> > sigma =3D 1e4;
>
> > Wr =3D riceanpdf(x,gamma,sigma); =A0 =A0 % get PDF
>
> > trapz(x,Wr)
>
> > function Wr =3D riceanpdf(e,gamma,sigma)
> > %% Ricean pdf
>
> > q =3D 2.*e.*sqrt(gamma.*(1+gamma))./sqrt(sigma);
>
> > term1 =3D 2.*e.*(1+gamma)./sigma;
> > term2 =3D exp(1.*((1+gamma).*e.^2+gamma.*sigma)./sigma);
> > term3 =3D besseli(0,q);
>
> > Wr =3D term1.*term2.*term3;
>
> > Wr(isnan(Wr)) =3D 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). =A0How 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 =3D length(x).*Wr./(sum(Wr).*max(x));
>
> > But that doesn't work in this case since the spacing in the xvector
> > are not constant.
>
> > Thanks!
>
> =A0 Your variable of integration, x, is going backwards, which is why you=
are getting negative answers. =A0When you write x =3D e/b with b increasin=
g, x must decrease.
>
> =A0 This also has the effect of making the spacing in x very nonuniform,=
so 'trapz' could have accuracy difficulties at the beginning where the jum=
ps in x are largest. =A0The first jump is 0.04 which is very much larger th=
an the last one at 0.000001 . =A0Why are you using this kind of spacing and=
why go backwards?
>
> Roger Stafford
I'm trying to follow some equations from a paper, and that's the way
it is described. What I'm trying now is reordering my x vector so it
is increasing, although I'm a little hesitant to change around
variables when it's not mentioned in the paper.
I don't know if you have time or access to this paper, but the one I'm
talking about is by Trevorrow in 2005 called "The use of moored
inverted echo sounders for monitoring mesozooplankton and fish near
the ocean surface." I found it on Google Scholars, but you might need
a subscription to view it. If you can get it, the equations in
question are equations 4 through 6.
Thanks.
