From: carl on

"John D'Errico" <woodchips(a)rochester.rr.com> wrote in message
news:hl3v5i$pi0$1(a)fred.mathworks.com...
> "carl" <carl@.com> wrote in message
> <4b757bff$0$283$14726298(a)news.sunsite.dk>...
>>
>> "Brian Borchers" <borchers.brian(a)gmail.com> wrote in message
>> news:5a9bc554-5cf9-47fd-a610-b98217017a7a(a)g28g2000prb.googlegroups.com...
>> >A probability density function (pdf) has to be integrated over some
>> > range of x values to obtain a probability. If the pdf is nonzero over
>> > a narrow range it's quite easy for the maximum of the pdf to be larger
>> > than one, even though the integral of the pdf from x=-infinity to x=
>> > +infinity is 1.
>> >
>> > For example, consider a random variable X that is uniformly
>> > distributed on the interval [0,1/2]. The pdf is
>> >
>> > f(x)=2 0<=x<=1/2.
>> > f(x)=0 x<0 or x>1/2.
>> >
>> > The probability that x is between 0 and 0.1 is
>> >
>> > P(0<=x<=0.1)=int(f,x=0..0.1)=0.2.
>>
>> Ok I thought that mvnpdf corresponded to this expression:
>>
>>
>> http://upload.wikimedia.org/math/a/d/4/ad4c63257208b495d1084a74a15e0113.png
>>
>> which in the litterature is both referred to as the multivariate gaussian
>> distribution, multivariate probability density and probability mass
>> function.
>>
>> And that the plot would look like this:
>>
>>
>> http://upload.wikimedia.org/wikipedia/commons/7/74/Normal_Distribution_PDF.svg
>>
>> depending on the parameters sigma and the mean. But cleary that this is
>> not mvnpdf. Maybe its best to implement things from scratch to understand
>> how they work.
>
> It does correspond to that expression. But you need
> to appreciate that that expression can easily be larger
> than 1.
>
> Only the integral must be 1.



Ok but when I do:

sum(prob)

I get:

1.2987e+006

which is not 1! So the sum/integral over the density returned by mvnpdf can
also be larger than 1.


From: John D'Errico on
"carl" <carl@.com> wrote in message <4b7587c5$0$272$14726298(a)news.sunsite.dk>...
>
> "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message
> news:hl3v5i$pi0$1(a)fred.mathworks.com...
> > "carl" <carl@.com> wrote in message
> > <4b757bff$0$283$14726298(a)news.sunsite.dk>...
> >>
> >> "Brian Borchers" <borchers.brian(a)gmail.com> wrote in message
> >> news:5a9bc554-5cf9-47fd-a610-b98217017a7a(a)g28g2000prb.googlegroups.com...
> >> >A probability density function (pdf) has to be integrated over some
> >> > range of x values to obtain a probability. If the pdf is nonzero over
> >> > a narrow range it's quite easy for the maximum of the pdf to be larger
> >> > than one, even though the integral of the pdf from x=-infinity to x=
> >> > +infinity is 1.
> >> >
> >> > For example, consider a random variable X that is uniformly
> >> > distributed on the interval [0,1/2]. The pdf is
> >> >
> >> > f(x)=2 0<=x<=1/2.
> >> > f(x)=0 x<0 or x>1/2.
> >> >
> >> > The probability that x is between 0 and 0.1 is
> >> >
> >> > P(0<=x<=0.1)=int(f,x=0..0.1)=0.2.
> >>
> >> Ok I thought that mvnpdf corresponded to this expression:
> >>
> >>
> >> http://upload.wikimedia.org/math/a/d/4/ad4c63257208b495d1084a74a15e0113.png
> >>
> >> which in the litterature is both referred to as the multivariate gaussian
> >> distribution, multivariate probability density and probability mass
> >> function.
> >>
> >> And that the plot would look like this:
> >>
> >>
> >> http://upload.wikimedia.org/wikipedia/commons/7/74/Normal_Distribution_PDF.svg
> >>
> >> depending on the parameters sigma and the mean. But cleary that this is
> >> not mvnpdf. Maybe its best to implement things from scratch to understand
> >> how they work.
> >
> > It does correspond to that expression. But you need
> > to appreciate that that expression can easily be larger
> > than 1.
> >
> > Only the integral must be 1.
>
>
>
> Ok but when I do:
>
> sum(prob)
>
> I get:
>
> 1.2987e+006
>
> which is not 1! So the sum/integral over the density returned by mvnpdf can
> also be larger than 1.
>


No. I think you misunderstand what an integral is,
or at least have forgotten.

A sum is not an integral. They are different things.

John
From: Steven Lord on

"carl" <carl@.com> wrote in message
news:4b7587c5$0$272$14726298(a)news.sunsite.dk...

*snip*

> Ok but when I do:
>
> sum(prob)
>
> I get:
>
> 1.2987e+006
>
> which is not 1!

That is a correct statement and the correct behavior for SUM.

> So the sum/integral over the density returned by mvnpdf can also be larger
> than 1.

Only half of that statement is correct.

The sum of the density _at the points at which you evaluated it_ can be
greater than 1.
The integral of the density cannot be greater than 1 (modulo roundoff
error.)

Let's take a simple function whose integral we know to be 1.

x = [-1 0 0 0.5 1 1 2];
y = [0 0 1 1 1 0 0];
plot(x, y, '-o')
axis equal

Assuming that the function is zero outside the range [0, 1], the area under
this function is a square with side 1, and the integral of the function is
the area of the square. Let's double-check that its integral is 1:

trapz(x, y)

Now how about the sum of the y values?

sum(y)

In fact, you can make the sum of the y values arbitrarily large without
changing the integral of the function. Change delta in the code below and
see how the integral and the sum change.

delta = 0.1;
t = 0:delta:1;
x = [-1 0 t 1 2];
y = [0 0 ones(size(t)) 0 0];
plot(x, y, '-o')
axis equal
integral = trapz(x, y)
thesum = sum(y)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ