Modelonzekerheid en steekproefverdelingen

Introductie tot lineaire modellering in Python

Jason Vestuto

Data Scientist

Populatie niet beschikbaar

Histogram van dagenaantal versus temperatuurbins, Dagelijkse maximumtemperaturen in augustus

Introductie tot lineaire modellering in Python

Steekproef als populatiemodel

2 histogrammen, één voor steekproef en één voor populatie, beide met genormaliseerd dagenaantal versus temperatuurbins; de staafhoogtes lijken op elkaar

Introductie tot lineaire modellering in Python

Steekproefstatistiek

Histogram voor één steekproef, dagenaantal versus temperatuurbins

Introductie tot lineaire modellering in Python

Bootstrap-resampling

3 histogrammen, één per steekproef, elk met een ander centrum, op assen van dagenaantal versus temperatuurbins

Introductie tot lineaire modellering in Python

Resampleverdeling

Histogram van gemiddelden, met assen steekproefaantal versus gemiddelde temperatuurbins

Introductie tot lineaire modellering in Python

Bootstrap in code

# Use sample as model for population
population_model = august_daily_highs_for_2017
# Simulate repeated data acquisitions by resampling the "model"
for nr in range(num_resamples):
    bootstrap_sample = np.random.choice(population_model, size=resample_size, replace=True)
    bootstrap_means[nr] = np.mean(bootstrap_sample)
# Compute the mean of the bootstrap resample distribution
estimate_temperature = np.mean(bootstrap_means)
# Compute standard deviation of the bootstrap resample distribution
estimate_uncertainty = np.std(bootstrap_means)
Introductie tot lineaire modellering in Python

Terugleggen

# Define the sample of notes
sample = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
# Replace = True, repeats are allowed
bootstrap_sample = np.random.choice(sample, size=4, replace=True)
print(bootstrap_sample)
C C F G
Introductie tot lineaire modellering in Python

Terugleggen

# Replace = False
bootstrap_sample = np.random.choice(sample, size=4, replace=False)
print(bootstrap_sample)
C G A F
# Replace = True, more lengths are allowed
bootstrap_sample = np.random.choice(sample, size=16, replace=True)
print(bootstrap_sample)
C C F G C G A E F D G B B A E C
Introductie tot lineaire modellering in Python

Laten we oefenen!

Introductie tot lineaire modellering in Python

Preparing Video For Download...