Created
September 20, 2012 02:08
-
-
Save gu-mi/3753566 to your computer and use it in GitHub Desktop.
Reject the first 37% ?
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
## I came across a Chinese science blog which discusses an interesting stuff that girls should reject | |
## the first 37% (for 1/e = 36.79%) pursuers in her life. A little R simulation as outlined in the | |
## gist is shown below just for fun. In the snippet, m is the total number of boys you can choose. | |
## In other words, they are potential husband for you. Larger number means high "quality" but these | |
## numbers are randomly sampled, i.e., you don’t know whether the one who just walks into your life | |
## is your Mr. Right or not. You reject the first m/e people (probably without any reason...), where | |
## e is the Euler’s number, and choose from the rest of the m people. If you find any one of the | |
## remaning boys better than the best boy you saw earlier in the first m/e ones, then you choose that | |
## guy; otherwise, you have to make do with the last guy for the rest of your life... | |
## Well, girls basically don’t behave like what stated above...but one thing seems interesting and | |
## probably makes sense: it’s too early to laugh when you meet a nearly-perfect boy very early | |
## (<37% for sure). If your Mr. Right shows up just after 37%, I would say you are lucky enough :) | |
m = 30; sim = 10000 | |
cut = round(m/exp(1)) | |
v1 = (1:cut); v2 = (cut+1):m | |
mat = matrix(0, nr = m, nc = sim) | |
love = as.numeric(sim) | |
for (j in 1:sim){ | |
mat[ ,j] = sample(seq(1,m),replace=FALSE) | |
} | |
for (j in 1:sim){ | |
if(any(mat[v2,j] > max(mat[v1,j]))) | |
love[j] = mat[v2,j][which(mat[v2,j] > max(mat[v1,j]))[1]] | |
else | |
love[j] = mat[m,j] | |
} | |
hist(love) | |
sum(love == m)/sim |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment