SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Alan I. <ai...@am...> - 2007年09月26日 21:09:56
Is there a standard function or practice for
plotting the CDF of a series? (I am aware
of the output of hist.)
Thank you,
Alan Isaac
From: Tommy G. <tg...@ma...> - 2007年09月26日 23:08:15
On Sep 26, 2007, at 5:09 PM, Alan Isaac wrote:
> Is there a standard function or practice for
> plotting the CDF of a series? (I am aware
> of the output of hist.)
Without really knowing what CDF is (I am assuming
it is Cumulative Density Fucntion or something similar).
I would suggest taking a look at numpy and the histogram
and cumsum functions therein.
Cheers
 Tommy
From: Robert K. <rob...@gm...> - 2007年09月27日 00:11:41
Alan Isaac wrote:
> Is there a standard function or practice for
> plotting the CDF of a series? (I am aware
> of the output of hist.)
import numpy as np
from matplotlib import pylab
x = ... # whatever
n = len(x)
x2 = np.repeat(x, 2)
y2 = np.hstack([0.0, np.repeat(np.arange(1,n) / float(n), 2), 1.0])
pylab.plot(x2, y2)
-- 
Robert Kern
"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
From: Alan G I. <ai...@am...> - 2007年09月27日 14:56:09
On 2007年9月26日, Robert Kern apparently wrote:
> n = len(x)
> x2 = np.repeat(x, 2)
> y2 = np.hstack([0.0, np.repeat(np.arange(1,n) / float(n), 2), 1.0])
> pylab.plot(x2, y2)
OK, that's pretty slick.
I did not think about ``repeat``.
Thanks,
Alan
From: Alan G I. <ai...@am...> - 2007年09月28日 04:13:47
After thinking it over, I did not go for
Robert or David's cool numpy tricks, but
I'll append a simple object in case someone
else wants to do more.
Cheers,
Alan Isaac
class EmpiricalCDF(object):
 '''Empirical cdf.
 First point will be (xmin,0).
 Last point will be (xmax,1).
 '''
 def __init__(self, data, sortdata=True):
 if sortdata:
 data = N.sort(data)
 self.data = data
 self.nobs = len(data)
 def gen_xp(self):
 data, nobs = self.data, self.nobs
 prob = N.linspace(0, 1, nobs+1)
 xsteps = ( data[(idx)//2] for idx in xrange(2*nobs) )
 psteps = ( prob[(idx+1)//2] for idx in xrange(2*nobs) )
 return xsteps, psteps
 def get_steps(self):
 '''Return: 2-tuple of arrays,
 the data values and corresponding cumulative 
 probabilities.
 '''
 xsteps, psteps = self.gen_xp()
 return N.fromiter(xsteps,'f'), N.fromiter(psteps,'f')
From: David H. <dav...@gm...> - 2007年09月27日 14:03:44
Hi Alan,
There is an empiricalcdf function in scipy/sandbox/dhuard/stats.py
It's not fancy but it might do what you want.
David
2007年9月26日, Alan Isaac <ai...@am...>:
>
> Is there a standard function or practice for
> plotting the CDF of a series? (I am aware
> of the output of hist.)
>
> Thank you,
> Alan Isaac
>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Alan G I. <ai...@am...> - 2007年09月27日 16:04:22
On 2007年9月27日, David Huard apparently wrote:
> scipy/sandbox/dhuard/stats.py 
Well, I also did not think of a double application of 
argsort to rank the observations. Nice. OK, I've got plenty 
to work with now.
Thanks,
Alan
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /