inf-428-data-analytics-online

Distributions and Confidence Intervals

Normal Distribution

Generating Normal Distribution

see notebook

Confidence Interval

For example in Python the following code calculates the confidence interval of a single draw from a distribution with given mean and standard deviation

import numpy as np
import scipy
test = np.array([1,2,3,2,1,4]);
scipy.stats.norm.interval(0.95, test1.mean(), test1.std())

CONFIDENCE INTERVAL OF THE MEAN

Confidence Interval of the Mean in Practice

In Python

# in Python
import scipy
# assume a is an array
sample_mean=np.mean(a);
standard_error=scipy.stats.sem(a)

scipy.stats.t.interval(0.95, len(a)-1, loc=sample_mean, scale=standard_error)