Skip to content

Commit e3f1673

Browse files
author
User
committed
update
1 parent ce468b7 commit e3f1673

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

ab_testing/cdfs_and_percentiles.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
from scipy.stats import norm
4+
5+
6+
mu = 170
7+
sd = 7
8+
9+
10+
# generate samples from our distribution
11+
x = norm.rvs(loc=mu, scale=sd, size=100)
12+
13+
# maximum likelihood mean
14+
x.mean()
15+
16+
# maximum likelihood variance
17+
x.var()
18+
19+
# maximum likelihood std
20+
x.std()
21+
22+
# unbiased variance
23+
x.var(ddof=1)
24+
25+
# unbiased std
26+
x.std(ddof=1)
27+
28+
# at what height are you in the 95th percentile?
29+
norm.ppf(0.95, loc=mu, scale=sd)
30+
31+
# you are 160 cm tall, what percentile are you in?
32+
norm.cdf(160, loc=mu, scale=sd)
33+
34+
# you are 180 cm tall, what is the probability that someone is taller than you?
35+
1 - norm.cdf(180, loc=mu, scale=sd)

0 commit comments

Comments
 (0)