I used Method of Moments to fit negative binomial, poisson and geometric distributions.
Basic idea: get empirical first, second, etc. moments, then derive distribution parameters from these moments.
You can see the details in this question: Fitting Distributions with Maximum Likelihood Method
And now i want to implement this method for gamma distribution;
For Gamma distribution i applied this;
import pandas as pd
from scipy.stats import gamma
x = pd.Series(x)
mean = x.mean()
var = x.var()
likelihoods = {}
alpha = (mean**2)/var
beta = alpha / mean
likelihoods['gamma'] = x.map(lambda val: gamma.pdf(val, alpha)).prod()
However, the likelihood value is infinite in the results for Gamma Distribution. So, I'm not sure I can apply it correctly this method for Gamma.
Is there anyone who can help for that?