Bootstrap güven aralıkları

Python ile İstatistiksel Düşünme (Bölüm 2)

Justin Bois

Lecturer at the California Institute of Technology

Bootstrap kopya (replicate) fonksiyonu

def bootstrap_replicate_1d(data, func):
    """Generate bootstrap replicate of 1D data."""
    bs_sample = np.random.choice(data, len(data))
    return func(bs_sample)

bootstrap_replicate_1d(michelson_speed_of_light, np.mean)
299859.20000000001
bootstrap_replicate_1d(michelson_speed_of_light, np.mean)
299855.70000000001
bootstrap_replicate_1d(michelson_speed_of_light, np.mean)
299850.29999999999
Python ile İstatistiksel Düşünme (Bölüm 2)

Birçok bootstrap kopyası

bs_replicates = np.empty(10000)

for i in range(10000): bs_replicates[i] = bootstrap_replicate_1d( michelson_speed_of_light, np.mean)
Python ile İstatistiksel Düşünme (Bölüm 2)

Bootstrap kopyalarının histogramını çizmek

_ = plt.hist(bs_replicates, bins=30, normed=True)
_ = plt.xlabel('mean speed of light (km/s)')
_ = plt.ylabel('PDF')
plt.show()
Python ile İstatistiksel Düşünme (Bölüm 2)

Ortalamanın bootstrap tahmini

ch2-2.011.png

Python ile İstatistiksel Düşünme (Bölüm 2)

Bir istatistiğin güven aralığı

  • Ölçümleri tekrar tekrar yapsaydık, gözlenen değerlerin p%'i p% güven aralığı içinde yer alırdı.
Python ile İstatistiksel Düşünme (Bölüm 2)

Bootstrap güven aralığı

conf_int = np.percentile(bs_replicates, [2.5, 97.5])
array([ 299837.,  299868.])

ch2-2.016.png

Python ile İstatistiksel Düşünme (Bölüm 2)

Hadi pratik yapalım!

Python ile İstatistiksel Düşünme (Bölüm 2)

Preparing Video For Download...