CommencerCommencer gratuitement

Try other candidate distributions

Proper choice of input probability distributions is key for performing Monte Carlo simulations. In the video, three distributions were evaluated to determine which was the best fit for the age variable. Those distributions were the Laplace, normal, and exponential distributions. The normal distribution was the best fit.

In this exercise, you'll see if you can find a distribution that improves upon the fit of the normal distribution! You'll evaluate the fitting of uniform, normal, and exponential distributions. The diabetes dataset has been loaded as a DataFrame, dia. Will the normal distribution still be the best?

The following libraries have been imported for you: pandas as pd, scipy.stats as st, and numpy as np.

Cet exercice fait partie du cours

Monte Carlo Simulations in Python

Afficher le cours

Instructions

  • Use .fit() to fit a distribution to the age data; then use .nnlf() to obtain the Maximum Likelihood Estimation (MLE) value of the fitting.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

distributions = [st.uniform, st.norm, st.expon]
mles = []
for distribution in distributions:
    # Fit the distribution and obtain the MLE value
    pars = distribution.____
    mle = distribution.____
    mles.append(mle)
print(mles)
Modifier et exécuter le code