Reputation: 687
I have a gamma distribution with shape and scale parameter 2.126, 0.370.
You can plot it with following code:
shape, scale = 2.126, 0.370 # mean=4, std=2*sqrt(2)
s = np.random.gamma(shape, scale, 1000)
weights = np.ones_like(s)/float(len(s))
plt.hist(s, 30,weights=weights)
The parameters are originally used to describe the walking distance between home and a public transport node with unit km
. Now I want to transfer the unit to m
.
How could I keep the same shape, only with difference on the unit of x Axis.
What should the new shape and scale parameters be?
To be more clear, I want the x axis scales to become 500, 1000, 1500 ... instead of 0.5, 1, 1.5 ...
Upvotes: 2
Views: 149
Reputation: 687
Thanks for @sciroccorics answer:
s = 1000*np.random.gamma(shape, scale, 1000)
fit_alpha, fit_loc, fit_beta=st.gamma.fit(data)
data=gamma.rvs(fit_alpha,loc=fit_loc,scale=fit_beta,size=5000)
Upvotes: 0
Reputation: 2427
Replace your second line by:
s = 1000*np.random.gamma(shape, scale, 1000)
Upvotes: 1