[Tutor] Fwd: Gamma distribution function

Jervis Whitley jervisau at gmail.com
Tue Jan 13 23:59:21 CET 2009


---------- Forwarded message ----------
From: Jervis Whitley <jervisau at gmail.com>
Date: Wed, Jan 14, 2009 at 9:26 AM
Subject: Re: [Tutor] Gamma distribution function
To: culpritNr1 <ig2ar-saf1 at yahoo.co.uk>




On Wed, Jan 14, 2009 at 9:11 AM, culpritNr1 <ig2ar-saf1 at yahoo.co.uk> wrote:

>
> The python documentation on this functionality is extremely poor. Look
> >>> help("scipy.stats.distributions.poisson.rvs")
> Help on method rvs in scipy.stats.distributions.poisson:
> scipy.stats.distributions.poisson.rvs = rvs(self, *args, **kwds) method of
> scipy.stats.distributions.poisson_gen instance
>
> Do you understand what's going on?
>
> Thanks,
>
> culpritNr1
>
>
> --
> View this message in context:
> http://www.nabble.com/Gamma-distribution-function-tp21444899p21445597.html
> Sent from the Python - tutor mailing list archive at Nabble.com.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


Your previous email said you wanted to sample from the poisson function,
which is what that rvs method is doing, taking random samples from a poisson
distribution of lambda = 1 in your case. They also provide a means to shift
the function from a nominal x crossing of 0 using the second argument, in
your case you have used 2. So you were sampling from a function of mean 1
shifted right by 2.

The below has been taken from the poisson documentation itself:

print stats.distributions.poisson.__doc__
A poisson discrete random variable.

    Discrete random variables are defined from a standard form.
    The standard form may require some other parameters to complete
    its specification.  The distribution methods also take an optional
location
    parameter using loc= keyword.  The default is loc=0.  The calling form
    of the methods follow:

    poisson.rvs(mu,loc=0)
        - random variates

    poisson.pmf(x,mu,loc=0)
        - probability mass function

    poisson.cdf(x,mu,loc=0)
        - cumulative density function

    poisson.sf(x,mu,loc=0)
        - survival function (1-cdf --- sometimes more accurate)

    poisson.ppf(q,mu,loc=0)
        - percent point function (inverse of cdf --- percentiles)

    poisson.isf(q,mu,loc=0)
        - inverse survival function (inverse of sf)

    poisson.stats(mu,loc=0,moments='mv')
        - mean('m',axis=0), variance('v'), skew('s'), and/or kurtosis('k')

    poisson.entropy(mu,loc=0)
        - entropy of the RV

    Alternatively, the object may be called (as a function) to fix
       the shape and location parameters returning a
       "frozen" discrete RV object:

    myrv = poisson(mu,loc=0)
        - frozen RV object with the same methods but holding the
            given shape and location fixed.

    You can construct an aribtrary discrete rv where P{X=xk} = pk
    by passing to the rv_discrete initialization method (through the values=
    keyword) a tuple of sequences (xk,pk) which describes only those values
of
    X (xk) that occur with nonzero probability (pk).

Poisson distribution

poisson.pmf(k, mu) = exp(-mu) * mu**k / k!
for k >= 0

If you are after a probability at a given k (which it now sounds like you
may be after) you might be interested in the
pmf method.

(Sorry I did a reply instead of reply-all)

Cheers,

Jervis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090114/87629548/attachment.htm>


More information about the Tutor mailing list