quantiles of a student distribution

Robert Kern robert.kern at gmail.com
Wed Aug 26 15:30:08 EDT 2009


On 2009-08-26 11:49 AM, Colin J. Williams wrote:
> Pierre wrote:
>> Hello...
>>
>> Do you know how I can calculate the quantiles of a student
>> distribution in pyhton ?
>>
>> Thanks
> You might look at:
> http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/python/special.html

[Please pardon the piggybacking. I have not gotten the original, yet.]

Using scipy:

In [1]: from scipy import stats

In [2]: import numpy as np

In [3]: x = np.linspace(-1.0, 1.0, 21)

In [4]: x
Out[4]:
array([-1. , -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1,  0. ,
         0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9,  1. ])

In [5]: ndof = 10

In [6]: stats.t.cdf(x, ndof)
Out[6]:
array([ 0.17044657,  0.19463963,  0.22115021,  0.24994379,  0.28092759,
         0.3139468 ,  0.3487837 ,  0.3851603 ,  0.4227446 ,  0.46116036,
         0.5       ,  0.53883964,  0.5772554 ,  0.6148397 ,  0.6512163 ,
         0.6860532 ,  0.71907241,  0.75005621,  0.77884979,  0.80536037,
         0.82955343])


-- 
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




More information about the Python-list mailing list