Last active
April 5, 2021 20:22
-
-
Save nwjlyons/7aeb3206250163dba137c4a6298259d5 to your computer and use it in GitHub Desktop.
Regression to the mean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from collections import Counter | |
def regression_to_the_mean(n): | |
data = [random.randint(1, 10) for x in range(n)] | |
return sum(data) // len(data) | |
# 10 | |
Counter([regression_to_the_mean(10) for x in range(50)]).most_common() | |
>>> [(5, 23), (4, 14), (6, 6), (7, 4), (3, 3)] | |
# 100 | |
Counter([regression_to_the_mean(100) for x in range(50)]).most_common() | |
>>> [(5, 41), (4, 5), (6, 4)] | |
# 1_000 | |
Counter([regression_to_the_mean(1_000) for x in range(50)]).most_common() | |
>>> [(5, 50)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The more data points, the less variance in the mean.