From: AA Swamy on
Hi,

When i use ksdensity funtion and integrate the area under the PDF, I get values gr than 1. Why do i get such values?

I used default values for all parameters in the ksdensity.

Thanks in advance for the support

Anandhi

Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <gsptak$e7f$1(a)fred.mathworks.com>...
> Dan wrote:
> > I have a simple question about the use of the ksdensity function to estimate probability density. I modified an example from the product help feature that uses a normally-distributed random number generator as follows: x = [randn(300000,1); randn(300000,1)]. This obviously generates a 600000-point vector of normally-distributed random numbers. It plotted a Gaussian-like curve with a maximum of about 0.4. Integrating under the curve gave a value of 0.9999, as would be expected. Then, I modified the expression as follows: x = [randn(300000,1)/100; randn(300000,1)/100]. The resulting curve was Gaussian-like and had a maximum of about 40 with, obviously, smaller values on the abscissa, and again integrated to 0.9999. The values on the abscissa are in the range of what I am used to using, but I normally expect the "PDF" values to be less than 1, but they can't be because of the
requirement of
> > the integration yielding a value close to 1. So, after all of that discussion, I am interested in knowing how to meaningfully normalize the ordinate values. My first impulse is to normalize with the sum of the pdf estimates. This would give a kind of probability mass function, where the SUM of the pmf values equals one (Smith, "Digital Signal Processing", pp. 22-23). Any thoughts? Thanks.
>
> Dan, the values that KSDENSITY are already normalized in the most meaningful sense there is: they are values from a PDF that integrates to 1. Scaling them so that they sum to 1 would be pointless, because there's no good reason why a set of PDF values _ought_ to sum to 1. In addition, the scale factor that you'd use would depend on how many points you had, and where they were.
>
> If you want to discretize the distribution, that is perfectly reasonable, but you need to take differences of CDF values (which KSDENSITY will return, by the way). You can, I suppose, approximate that by computing the PDF on a fine grid of points, and divide the PDF values by the grid spacing, by why? You can get the corr3ect result using the CDF.
>
> Hope this helps.
From: michael scheinfeild on
there is issue of final number accuracy so you cant reach one any way
0.1+0.2+0.7 ~ 1
also if you try to make gaussian window it matlab and test the normilized sum it is not exactly one it also depends on you pc , float numbers represented using the mantissa
so finaly you might have all number represented as 53 or 64 bits . this issue generally not influance you algorithms and there are ways of correcting like adding some epsilon
From: AA Swamy on
thanks micheal,

I can understand when the sum(prob) comes to ~ 1 but I get sums close tp 2?
can you elaborate your statement
"there are ways of correcting like adding some epsilon ".
I would like to get values close to ~1. what are the ways in correcting?

thanks in advance
AA

"michael scheinfeild" <yomholedet(a)gmail.com> wrote in message <hl44ph$p5$1(a)fred.mathworks.com>...
> there is issue of final number accuracy so you cant reach one any way
> 0.1+0.2+0.7 ~ 1
> also if you try to make gaussian window it matlab and test the normilized sum it is not exactly one it also depends on you pc , float numbers represented using the mantissa
> so finaly you might have all number represented as 53 or 64 bits . this issue generally not influance you algorithms and there are ways of correcting like adding some epsilon
From: Peter Perkins on
On 2/12/2010 1:18 PM, AA Swamy wrote:
> thanks micheal,
>
> I can understand when the sum(prob) comes to ~ 1 but I get sums close tp
> 2? can you elaborate your statement
> "there are ways of correcting like adding some epsilon ".
> I would like to get values close to ~1. what are the ways in correcting?

AA, you're going to have to give a us a lot more to go on. An example to demonstrate what you're seeing.