05 Confidence interval example
05 Confidence interval example#
%%html
<iframe width="700" height="400" src="https://www.youtube.com/embed/SeQeYVJZ2gE/" frameborder="0" allowfullscreen></iframe>
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats, special
x = np.array(142 * [1] + 108 * [0])
sns.distplot(x)
/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/seaborn/distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
warnings.warn(msg, FutureWarning)
<AxesSubplot:ylabel='Density'>
xbar = x.mean()
s = x.std(ddof=1)
mu_xbar = xbar
sigma_xbar = s/np.sqrt(len(x))
stats.norm.interval(0.99, loc=mu_xbar, scale=sigma_xbar)
(0.487140053938945, 0.6488599460610549)