I am trying to understand how to fit a probability distribution function, such as Pearson type 3, to a data set (specifically, mean annual rainfall in an area). I've read some questions about this, but I still miss something and the fitting doesn't get right. As for now my code is this (the specific data file can be downloaded from here): import numpy as np import matplotlib.pyplot as plt from scipy.stats import pearson3 year,mm = np.loadtxt('yearly_mm_sde_boker_month_1960_2016.csv',delimiter=',').T fig,ax=plt.subplots(1,2,figsize=(2*1.62*3,3)) ax[0].plot(year,mm) dump=ax[1].hist(mm) size = len(year) param = pearson3.fit(mm) pdf_fitted = pearson3.pdf(year, *param[:-2], loc=param[-2], scale=param[-1]) * size plt.plot(pdf_fitted, label=dist_name) plt.xlim(0,len(year)) plt.legend(loc='upper right') plt.show() What am I missing? Continue reading...