Get startedGet started for free

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.

This exercise is part of the course

Monte Carlo Simulations in Python

View Course

Exercise 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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)
Edit and Run Code