Skip to content Skip to sidebar Skip to footer

Fitting Data To A Probability Distribution, Maybe Skew Normal?

I am trying to fit my data to some kind of a probability distribution, so I can then generate random numbers based on the distribution. Below is what the data points look like, wit

Solution 1:

You can use scipy.stats.skewnorm.fit (see the docs here) to fit the data into a skew-normal distribution.

skewnorm.fit returns maximum likelihood estimate (MLE) for shape, location, and scale parameters from data.

from scipy import stats

# define your dataset here# let's make a sample with pre-defined parameters to demonstrate how it works
a, loc, scale = 1.6, -0.2, 3.2
data = stats.skewnorm(a, loc, scale).rvs(10000)

# estimate parameters of the sample
a_estimate, loc_estimate, scale_estimate = stats.skewnorm.fit(data)
print(a_estimate, loc_estimate, scale_estimate)

Output:

1.5784198343540448 -0.18066366859003175 3.1817350641737274

Post a Comment for "Fitting Data To A Probability Distribution, Maybe Skew Normal?"