[SciPy-User] scipy.stats: Sampling from an arbitrary probability distribution

Daniel Sabinasz d.sabinasz@googlemail....
Sun Jun 3 06:20:23 CDT 2012


Hi all,

I need to sample a random number from a distribution whose probability 
density function I specify myself. Is that possible using scipy.stats?

Here is what I have already:

import scipy.stats as st

class my_pdf(st.rv_continuous):
     def _pdf(self,x):
         return x*x/10.0

my_cv = my_pdf(name='my_pdf')

Can I now somehow sample a random number from my_cv?

Thanks in advance!

Daniel


More information about the SciPy-User mailing list