Plotting CDFs

Hi,

Does matplotlib provide functions to plot CDFs and PDFs (ala Matlab)?

Thanks,
Diwaker

···

--
Web/Blog/Gallery: http://floatingsun.net/blog

Matplotlib provides hist, an histogram plotting function.
For more involved computations, you would have to compute the pdf and
cdf first using scipy.stats. For empirical distributions, I think the
functions cumfreq and relfreq would do the job. For statistical
distributions, use distribution.pdf and distribution.cdf, where
distribution is norm, gamma, lognorm, …

David

2006/4/20, Diwaker Gupta <diwaker.lists@…287…>:

···

Hi,

Does matplotlib provide functions to plot CDFs and PDFs (ala Matlab)?

Thanks,
Diwaker

Web/Blog/Gallery: http://floatingsun.net/blog


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

[http://sel.as-us.falkag.net/sel?cmdlnk&kid0709&bid&3057&dat1642](http://sel.as-us.falkag.net/sel?cmdlnk&kid0709&bid&3057&dat1642)


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks for that tip David. Though it seems that even scipy doesn't do
exactly what I want. I'm looking to plot the empirical CDF.
scipy.stats.cumfreq divides the sample space into "bins" of fixed
size, while I want a step function at the given points.

I guess I'll just write my own.

···

On 4/20/06, David Huard <david.huard@...287...> wrote:

Matplotlib provides hist, an histogram plotting function.
For more involved computations, you would have to compute the pdf and cdf
first using scipy.stats. For empirical distributions, I think the functions
cumfreq and relfreq would do the job. For statistical distributions, use
distribution.pdf and distribution.cdf, where distribution is norm, gamma,
lognorm, ...

--
Web/Blog/Gallery: http://floatingsun.net/blog

Not too fast !!! I’m currently writing a histogram class to take take
of that, among other things. If you want to take a look at it and give
me some feedback, it would be great. I haven’t tested it extensively so
there are certainly some bugs. Basically, call
H = Histogram(data)
and then H.empirical_cdf(x) will return what you want, the interpolated function.

Cheers,

David

2006/4/22, Diwaker Gupta <diwaker.lists@…287…>:

histogramc.py (11.8 KB)

···

On 4/20/06, David Huard <david.huard@…287…> wrote:

Matplotlib provides hist, an histogram plotting function.
For more involved computations, you would have to compute the pdf and cdf

first using scipy.stats. For empirical distributions, I think the functions
cumfreq and relfreq would do the job. For statistical distributions, use
distribution.pdf and distribution.cdf, where distribution is norm, gamma,

lognorm, …

Thanks for that tip David. Though it seems that even scipy doesn’t do
exactly what I want. I’m looking to plot the empirical CDF.
scipy.stats.cumfreq divides the sample space into “bins” of fixed

size, while I want a step function at the given points.

I guess I’ll just write my own.

Web/Blog/Gallery: http://floatingsun.net/blog

Thats amazing, thanks David! I'll test it and get back to you. Right
now I just resorted to using Python RPY (interface to r-lang) to get
the ecdf.

Diwaker

···

On 4/22/06, David Huard <david.huard@...287...> wrote:

Not too fast !!! I'm currently writing a histogram class to take take of
that, among other things. If you want to take a look at it and give me some
feedback, it would be great. I haven't tested it extensively so there are
certainly some bugs. Basically, call
H = Histogram(data)
and then H.empirical_cdf(x) will return what you want, the interpolated
function.

--
Web/Blog/Gallery: http://floatingsun.net/blog

Posting code with a license is helpful.
Otherwise it is simply copyrighted these days.
Useful licenses include public domain, or BSD, or MIT.

Cheers,
Alan Isaac

···

On Sat, 22 Apr 2006, David Huard apparently wrote:

I'm currently writing a histogram class to take take of
that, among other things. If you want to take a look at it
and give me some feedback, it would be great.

Thanks for the tip,
I intended to submit the class to scipy once sufficiently tested and
robust. I thought that putting no license meant : do what you want with
it, and that’s what I wanted. Guess I’ll have to specify it. What a
strange world we live in…

David

2006/4/23, Alan G Isaac <aisaac@…310…>:

···

On Sat, 22 Apr 2006, David Huard apparently wrote:

I’m currently writing a histogram class to take take of
that, among other things. If you want to take a look at it
and give me some feedback, it would be great.

Posting code with a license is helpful.
Otherwise it is simply copyrighted these days.
Useful licenses include public domain, or BSD, or MIT.

Cheers,
Alan Isaac


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

David Huard wrote:

Thanks for the tip,
I intended to submit the class to scipy once sufficiently tested and
robust.

Excellent! Thank you.

I thought that putting no license meant : do what you want with
it, and that's what I wanted. Guess I'll have to specify it. What a
strange world we live in...

No, since sometime in the '70s, at least in the US, all original copyrightable
works are automatically copyrighted at their creation. If you want people to be
able to copy, modify, spindle, mutilate it, you have to give them permission.
The easiest thing to do for code is usually to just say that it's license is the
MIT or maybe BSD license (which we would prefer for scipy).

And don't get me started on the public domain.

···

--
Robert Kern
robert.kern@...287...

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
  -- Umberto Eco