help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in empirical_pdf?


From: Juan Pablo Carbajal
Subject: Re: Bug in empirical_pdf?
Date: Wed, 19 Jun 2013 16:03:14 +0200

On Tue, Jun 18, 2013 at 6:26 PM, Luke15153 <address@hidden> wrote:
> Hello,
>
> I tried to to get the probability distribution of measured data using the
> empirical_pdf function.
> But I get curious result.
>
> I made some tests with some data:
>
> empirical_pdf([1 2 3], [1 2 2 3]) returns
>
> 0.25 0.25 025
>
> but I would expect 0.25 *0.5* 0.25 as the 2 has a probability of 0.5.
>
> Is this a bug or a mistake of my own?
>
> Thanks for your help,
>
> Luke
>
>
>
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/Bug-in-empirical-pdf-tp4654443.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

It also puzzles me. As far as I understand these values should be similar
n=1e3;
dx = 0.1
x=-2:dx:2;
data=[zeros(1,floor(0.25*n)) ones(1,floor(0.5*n)) 1.5*ones(1,floor(0.25*n))];
sum(x.*empirical_pdf(x,data))*0.1
ans =    2.5000e-04
mean(data)
ans =  0.87500

I guess the call to discrete_pdf is not correct(?)

If you need a low order approximation of the "empirical pdf" you could use
[c b]=hist(data,x,round(1/dx));
This gives
sum(x.*c)*dx
ans =  0.87500
and
sum(c)*dx
ans = 1

statisticians please do not mailrage.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]