[SciPy-User] Gamma Distribution
Warren Weckesser
warren.weckesser at gmail.com
Tue May 20 11:48:55 EDT 2014
On Tue, May 20, 2014 at 11:28 AM, Klausen Schaefersinho <
klaus.schaefers at gmail.com> wrote:
> Hi,
>
> I have a short questions with regards to the parametrization of the gamma
> distribution in the scipy.stats module. According to wikipedia, there are
> three common ways to parameterize the gamma distrubution:
>
>
> 1. With a shape parameter<http://en.wikipedia.org/wiki/Shape_parameter>
> *k* and a scale parameter<http://en.wikipedia.org/wiki/Scale_parameter>θ.
> 2. With a shape parameter *α* = *k* and an inverse scale parameter
> β = 1/θ, called a rate parameter<http://en.wikipedia.org/wiki/Rate_parameter>
> .
> 3. With a shape parameter *k* and a mean parameter μ = *k*/β.
>
>
> Which one is used in Scipy and how do those parameters map to the a ,
> location and shape?
>
>
scipy.stats.gamma uses the first parametrization. wikipedia's `k`
corresponds to the shape parameter `a`, and `theta` corresponds to the
scale parameter. Like all of the distributions in scipy.stats, gamma also
has the location parameter `loc`, but it is usually not used.
This script reproduces the first plot on the wikipedia page.
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import gamma
x = np.linspace(0, 20, 201)
params = [(1, 2, 'r'), (2, 2, 'g'), (3, 2, 'b'), (5, 1, 'c'), (9, 0.5, 'y')]
for k, scale, clr in params:
lbl = r"k = %3.1f, $\theta$ = %3.1f" % (k, scale)
plt.plot(x, gamma.pdf(x, k, scale=scale), clr, label=lbl)
plt.title("Probability density function")
plt.legend()
plt.show()
Warren
Best Regards,
>
> Klaus
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at 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/20140520/2b039cac/attachment.html>
More information about the SciPy-User
mailing list