LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Monte Carlo Simulations in Python

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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)
Code bearbeiten und ausführen