Reputation: 6639
Am trying to plot a gamma distribution histogram using R
so i have
gam(10, 0.5)
I have previously calculated mean as
10* 0.5 = 5
So Am supposed to plot a histoigram of 100 observations with scale = 10 and shape = 0.5
So i have tried
x <- round(rgamma(100,shape = 0.5,rate = 10),1)
hist(x)
and i get
which is wrong as the mean is supposed to be 5 but my plot doesnt produce 5
Where am i going wrong?
Upvotes: 0
Views: 7251
Reputation: 433
This is the output from Alex's suggestion:
x <- round(rgamma(100,shape = 0.5,rate = 10),1)
hist(x)
Upvotes: 0
Reputation: 4995
Use scale
instead of rate
. So simulate your data as follows:
rgamma(100,shape = 0.5,scale = 10)
Read the documentation for more information.
Upvotes: 1