[SciPy-user] How to get a ppf for scipy.stats.beta
David Huard
david.huard at gmail.com
Fri Sep 19 08:52:31 EDT 2008
Hi Michael,
calling beta(a, b) will generate a "frozen distribution", that is one whose
parameters are fixed by you:
B = beta(a, b) # note that you should't pass x at this stage.
B.pdf(x)
B.cdf(x)
Now if you want to sample from the Beta, simply use the rvs method:
B.rvs(1000)
You can also simply do
beta.rvs(a,b,size=1000)
HTH,
David
On Fri, Sep 19, 2008 at 5:58 AM, Michael <mnandris at blueyonder.co.uk> wrote:
> Hi list,
>
> i am trying to use the percent point function to sample from the cdf for
> a beta distribution
>
> beta.ppf() returns an array instead of x; also you cannot create a ppf
> using the same idiom as beta.cdf(x,a,b,size=n)
>
> How do i go about getting the ppf for a beta dist?
>
> thanks in advance - much hairpulling on this <grr>
>
> Michael
>
>
> from scipy.stats import norm
> from scipy.stats import beta
> from scipy import linspace
>
> print norm.cdf(1.2) # 0.884930329778
> print norm.ppf(0.884930329778) # 1.2
>
> a=2
> b=7
> n=10e3
> x=linspace(0,1,n)
>
> cdf=beta.cdf(x,a,b,size=n)
> print cdf[2371] # 0.6
>
> B=beta(x,a,b,size=n)
>
> print B.cdf(2371)
> print B.ppf(0.6) # <-- should be 2371?
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080919/0a02e848/attachment.html>
More information about the SciPy-User
mailing list