Last active
February 23, 2020 03:33
-
-
Save hauselin/fcb9e1b10fa2d4f3b3fd16d84739a8e7 to your computer and use it in GitHub Desktop.
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
def simulate(simulations=1000, n=500, quantile=0.80): | |
correlations = np.zeros(simulations) | |
for i in range(simulations): | |
data = {"personality": np.random.randn( | |
n), "attract": np.random.randn(n)} | |
df = pd.DataFrame(data) | |
df['personality_attract'] = df['personality'] + df['attract'] | |
cutoff = df['personality_attract'].quantile(quantile) | |
df['outcome'] = np.where( | |
df['personality_attract'] > cutoff, 'dated', 'rejected') | |
dated = df.query('outcome == "dated"') | |
correlations[i] = dated.corr()['personality'][1] | |
return correlations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment