[SciPy-user] CDF/PDF Stats with SciPy

Ivo Maljevic ivo.maljevic@gmail....
Mon Jul 20 11:07:10 CDT 2009


Hi Omer,

For histogram you can either use histogram function from numpy/scipy:

from scipy import *

x = .... # some vector
h,bins = histogram(x,50,normed=True,new=True) # find the histogram, number
of bins = 50

or you can use pylab's version (good for plotting):

import matplotlib.pyplot as plt

count, bins, ignored = plt.hist(x, 50, normed=True)

For CDF you can use cumsum function (standard approach), but for smaller
number of data points I
prefer to use all the points, which is a neat trick:


from scipy import *

def my_cdf(x):

  bins = sort(x)
  cdf  = linspace(0,1,len(bins))
  return [bins, cdf]


2009/7/20 Omer Khalid <Omer.Khalid@cern.ch>

> Hi Everybody,
>
> I am new to Python and new to SciPy libraries. I wanted to take some ques
> from the experts here on the list before dive into SciPy world.
>
> I was wondering if some one could provide a rough guide about how to run
> two stats functions: Cumulative Distribution Function (CDF) and Probability
> Distribution Function (PDF).
>
> My use case is the following: I have a sampleSpaceList [] which have 1000
> floating point values. When a new floating point value is generated in my
> program, I would like to run both CDF and PDF on the sampleList for it and
> get the probabilty of value less or equal for CDF and probablity
> distribution for PDF.
>
> Many thanks in advance!
>
> Omer
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090720/bb4aebe5/attachment.html 


More information about the SciPy-User mailing list