In [160]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
In [209]:
pop=pd.Series(np.random.randint(low=0,high=100000, size=10000))
goal=Pop.mean()
print(goal)
49410.77
In [210]:
sample=pop.sample(n=200)
In [211]:
sample.mean()
Out[211]:
49402.605
In [212]:
sample.std()
Out[212]:
28805.574408680783
In [213]:
m=sample.mean()
sd=1.96*sample.std()/np.sqrt(200)
In [214]:
print(m-sd,',',m+sd)
45410.35606793104 , 53394.85393206897
In [215]:
boot_1d = []
for i in range(10000):
boot_mean = sample.sample(frac = 0.2,replace = True).mean()
boot_1d.append(boot_mean)
boot_1d = pd.DataFrame(boot_1d)
boot_1d.plot(kind='density')
Out[215]:
<matplotlib.axes._subplots.AxesSubplot at 0xf9d74a8>
In [216]:
boot_1d.mean()[0]
Out[216]:
49318.83029
In [217]:
d=1.96*boot_1d.std()[0]/np.sqrt(200)
In [218]:
print(boot_1d.mean()[0]-d,",",boot_1d.mean()[0]+d)
48684.96310343525 , 49952.69747656475
In [1]:
from IPython.core.display import display, HTML
display(HTML("<style>.container {width:90% !important;}</style>"))
In [ ]:
'슬기로운 건설 사무 자동화 > 2) Data 분석' 카테고리의 다른 글
| [python] 문장간 유사도 측정 (by 코사인 유사도) (0) | 2022.02.22 |
|---|
댓글