Reputation: 8816
With Scipy gamma distribution, one can only specify shape, loc, and scale. How do I create a gamma variable with shape and rate?
Upvotes: 4
Views: 4865
Reputation: 515
you can do it with the scale parameter, rate=1/scale
in R :
pgamma(1/2, 2, rate=5) and pgamma(1/2, 2, scale=0.2) are identical
Upvotes: 0
Reputation: 374
Accodring to wikipedia, rate is 1/scale, so you could use the scipy
distribution directly or wrap it with something like
def my_gamma(x,q,a,loc,freq,size,moments):
return scipy.stats.gamma(x, q, a,loc, 1.0/freq, size, moments)
Upvotes: 1
Reputation: 25369
Inverse scale (1/scale
) is rate parameter.
So if you have shape
and rate
you can create gamma rv with this code
>>> from scipy.stats import gamma
>>> rv = gamma(shape, scale = 1.0/rate)
Read more about different parametrizations of Gamma distribution on Wikipedia: http://en.wikipedia.org/wiki/Gamma_distribution
Upvotes: 7