help-octave
[Top][All Lists]

## Re: Calculating CDFs from PDFs

 From: Jonathan C. Webster Subject: Re: Calculating CDFs from PDFs Date: Wed, 01 Sep 2004 16:02:18 -0400 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1

try cumsum()
Jonathan

Joe Koski wrote:
With the octave hist function, I'm calculating approximate probability
density functions for some experimental data, and it is working well.

To get the cumulative distribution function from the probability
distribution, I reverted to my Fortran roots and wrote

% calculate cdf from pdf
sum_pdf=0;
for i = 1:num_bins
sum_pdf=sum_pdf+pdf(i);
cdf(i)=sum_pdf;
end

which also works well.

Question: is there a way of calculating cdf without resorting to the for
loop? The for loop approach seems very un-octave to me.

Obviously, this is not urgent, but perhaps educational.

Joe

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

reply via email to