We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ce468b7 commit e3f1673Copy full SHA for e3f1673
ab_testing/cdfs_and_percentiles.py
@@ -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