Distributiekeuzes evalueren

Monte Carlo-simulaties in Python

Izzy Weber

Curriculum Manager, DataCamp

Kansverdelingen voor variabelen kiezen

  1. Krijg een intuïtief begrip van data en beschikbare kansverdelingen
  2. Gebruik Maximum Likelihood (MLE) om kandidaatverdelingen te vergelijken
  3. Gebruik de Kolmogorov–Smirnov-toets om de goodness of fit te beoordelen
    • Kwantificeert de afstand tussen de empirische data-verdeling en de theoretische kandidaatverdeling
    • Gebruik scipy.stats.kstest() voor de berekening
Monte Carlo-simulaties in Python

Keuze van verdeling evalueren: leeftijd

results = []

list_of_dists = ["laplace", "norm", "expon"]
for i in list_of_dists: dist = getattr(st, i)
param = dist.fit(dia["age"])
result = st.kstest(dia["age"], i, args=param)
print(result)

Resultaten voor Laplace-, normale en exponentiële verdeling, in die volgorde:

KstestResult(statistic=0.09511179937112832, pvalue=0.0006239579389182981)
KstestResult(statistic=0.0615913626181368, pvalue=0.06703225234359811)
KstestResult(statistic=0.2536037941921312, pvalue=1.5202547969084796e-25)
Monte Carlo-simulaties in Python

Keuze van verdeling evalueren: leeftijd

Resultaten voor Laplace-, normale en exponentiële verdeling, in die volgorde:

KstestResult(statistic=0.09511179937112832, pvalue=0.0006239579389182981)
KstestResult(statistic=0.0615913626181368, pvalue=0.06703225234359811)
KstestResult(statistic=0.2536037941921312, pvalue=1.5202547969084796e-25)
Monte Carlo-simulaties in Python

Keuze van verdeling evalueren: tc-bloedserum

results = []
list_of_dists = ["laplace", "norm", "expon"]

for i in list_of_dists: dist = getattr(st, i) param = dist.fit(dia["tc"]) result = st.kstest(dia["tc"], i, args=param) print(result)

Resultaten voor Laplace-, normale en exponentiële verdeling, in die volgorde:

KstestResult(statistic=0.06435779928393615, pvalue=0.04915329841106708)
KstestResult(statistic=0.051165295747227724, pvalue=0.19085587687385897)
KstestResult(statistic=0.3318461436889846, pvalue=7.018486943525e-44)
Monte Carlo-simulaties in Python

Laten we oefenen!

Monte Carlo-simulaties in Python

Preparing Video For Download...