Auto Byte

Science AI

# 我们常听说的置信区间与置信度到底是什么？

``````love_soccer_prop = 0.65  # Real percentage of people who love soccer
total_population = 325*10**6  # Total population in the U.S. (325M)
num_people_love_soccer = int(total_population * love_soccer_prop)
num_people_dont_love_soccer = int(total_population * (1 - love_soccer_prop))
people_love_soccer = np.ones(num_of_people_who_love_soccer)
people_dont_love_soccer = np.zeros(num_
people_dont_love_soccer)
all_people = np.hstack([people_love_soccer, people_dont_love_soccer])
print np.mean(all_people)
# Output = 0.65000000000000002``````

``````for i in range(10):
sample = np.random.choice(all_people, size=1000)
print 'Sample', i, ':', np.mean(sample)
# Output:
Sample 0 : 0.641
Sample 1 : 0.647
Sample 2 : 0.661
Sample 3 : 0.642
Sample 4 : 0.652
Sample 5 : 0.647
Sample 6 : 0.671
Sample 7 : 0.629
Sample 8 : 0.648
Sample 9 : 0.627``````

``````values = []
for i in range(10000):
sample = np.random.choice(all_people, size=1000)
mean = np.mean(sample)
values.append(mean)
print np.mean(values)
# Output = 0.64982259999999992``````