Bobesh Bobesh - 1 year ago 131
R Question

Fit points with gamma CDF in python or R

I have series of plots looking like this:

python code:

a = np.array([4,4,4,4,5,5,5,6,6,6,6,6,6,6,7,7,7,8,8,8,9])
b = np.array([i/len(a) for i in range(1, len(a)+1)])
pl.plot(a,b, 'ro')

r code:

a <- c(4,4,4,4,5,5,5,6,6,6,6,6,6,6,7,7,7,8,8,8,9)
b <- seq(0,1,length = length(a))
plot(a, b, col = "red")


For some purpose I need to fit this points with best cumulative distribution function (CDF) of gamma distribution. Is there any way how to do this numerically in python or R? I am using winpython so i can import R code pretty straightfoward.

PS: I found this post but I dont understant it.

ira ira
Answer Source

Using package fitdistrplus:

a <- c(4,4,4,4,5,5,5,6,6,6,6,6,6,6,7,7,7,8,8,8,9)
fit <- fitdist(a, "gamma", lower = c(0,0))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download