Last active
February 23, 2020 03:33
-
-
Save hauselin/fcb9e1b10fa2d4f3b3fd16d84739a8e7 to your computer and use it in GitHub Desktop.
Revisions
-
hauselin renamed this gist
Feb 23, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
hauselin created this gist
Feb 23, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ 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