I use scipy.stats.logistic.fit() with fixed location value, to get an estimated scale parameter, while the residual does not hold normality from qqplot.
How should I improve it and how to visualize the errors? Is there other way to estimated the parameters for a logistic distribution?
For the data I used: shape (1000,150), the histogram shows a slightly right-tailed. use the maximum value in the dataset as location, and to estimate the parameter of scale.
Here is the code I used:
datalogitic= np.loadtxt(f"datalogiticfit.txt")
data=datalogitic[:,:51].flatten()
loc=data.max()
loc_lower=loc
loc_upper=loc
scale_lower=0
scale_upper=1000
dist = stats.logistic
bounds = [(loc_lower, loc_upper), (scale_lower,scale_upper)]
result = stats.fit(dist, data,bounds,method='mle')
print("Parameters of the Logistic Distribution are : ", result.params)
result.plot()
plt.show()
x = np.linspace(data.min(), data.max(), len(data))
cdf = stats.logistic.cdf(x, loc=result.params[0], scale=result.params[1])
plt.plot(x, cdf, label='Logistic CDF (Estimated Parameters)')
ecdf = ECDF(data)
plt.plot(ecdf.x, ecdf.y, label='Empirical CDF', linestyle="dashdot")
plt.legend()
plt.show()
When I looked at PDF of logistic provided in the page of
scipy.stats.logistic:
f(x) = \frac{\exp(-x)}
{(1+\exp(-x))^2}
The denominator part is not the same as found in the book Handbook of the Logistic Distribution (Statistics a Series of Textbooks and Monographs) (N. Balakrishnan).
f(x,u,s) = \frac{\exp(-(x-u)/s)}
{s*(1+\exp(-(x-u)/s)))^2}
Or they are equivalent?

Lets create a synthetic dataset:
You can fit with fixed parameters:
If you want to perform MLE by yourself, just state the likelihood:
Which also provides you uncertainty on parameter estimation (
hess_inv).