An interesting quiz was given in the past article of "ROKO HOUSE Siegel style logical investment technique".
[Quiz to ask investment sense
The problem is as follows.
In countries that only want boys, every house keeps growing children until a boy is born. When I have a girl, I will have another child. When a boy is born, he will no longer have children. What is the gender ratio in this country?
I intuitively thought, "Every house has one boy. Is there a little more girls because they keep having children until they are born?"
Click here for the answer article. I think it's a good idea to think for yourself before looking at it.
[Quiz to ask investment sense <Answer / Explanation>]
My intuition was wrong, so I actually tried to see if the answer was really correct.
We asked a million couples to make children until a boy was born.
Actually, it is impossible unless it is a dictatorship, so I did it with Python code.
Is this also a kind of Monte Carlo simulation?
Below are the results. I think it's a good idea to think for yourself before looking at it. (Hereafter spoilers)
I confirmed it with the following code.
python
import numpy as np
import pandas as pd
import random
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
dic = {'boys':[],
'girls':[]}
n_couples = 1000000
for i in range(n_couples):
n_girls = 0
n_boys = 0
while True:
baby = random.choice(['boy','girl'])
if baby=='boy':
n_boys += 1
break
else:
n_girls += 1
dic['boys'].append(n_boys)
dic['girls'].append(n_girls)
df = pd.DataFrame(dic)
df.index.name = 'parent_id'
df['total'] = df.sum(axis = 1)
print("Born from a million couples,")
print("Number of boys:{:>7}".format(df['boys'].sum()))
print("Number of girls:{:>7}".format(df['girls'].sum()))
print("\n Average number of births:{:.0f}Times".format(df['total'].mean()))
print("\n Household distribution by number of girls")
df2 = pd.DataFrame(df['girls'].value_counts())
df2.index.name = 'Number of girls'
df2.columns = ['Number of households']
df2e = df2.copy()
df2e.index.name = 'Number of girls'
df2e.columns = ['number of couples']
df2e.plot(kind = 'bar', figsize = (8,5))
df2
Below are the outputs and comments from the code.
python
Born from a million couples,
Number of boys: 1000000
Number of girls: 999687
The number of boys is, of course, one million. The number of girls is almost one million.
python
Average number of births: 2 times
On average, if you give birth twice, you will have a baby boy. I'm convinced that the probability is 50%, but I didn't know in advance.
** Distribution of households by number of girls **
Number of girls | Number of households |
---|---|
0 | 500580 |
1 | 249813 |
2 | 124471 |
3 | 62512 |
4 | 31319 |
5 | 15657 |
6 | 7718 |
7 | 3962 |
8 | 1935 |
9 | 1041 |
10 | 493 |
11 | 239 |
12 | 141 |
13 | 60 |
14 | 22 |
16 | 14 |
15 | 13 |
17 | 4 |
18 | 3 |
20 | 1 |
19 | 1 |
25 | 1 |
In about 50,000 households, half of the total, boys are born on the first birth and there are no girls. The probability is 50%.
The point that the total number of boys and girls is equal is that "50% of households have one boy and zero girls". When I thought about it intuitively, I overlooked this point.
And one girl will be about 25,000 households, two girls will be about 12,500 households, and so on. There is a 50% chance that a baby boy will be born per birth.
Finally, there was a couple who gave birth to 25 girls by the time they gave birth to a boy. thank you for your hard work.
The graph above shows this.
I didn't understand this quiz at first, but while writing the code, "When a boy is born, the couple will stop giving birth, and I'm kneading various things, but in the end, there is a 50% chance that which couple will give birth. Isn't it just that boys and girls continue to be born? "
A person with a good sense will immediately notice this fact, and a distribution image like the above graph will come to mind.
So the answer is
** "The male-female ratio in this country is 1: 1 (expected value)" **
Was the correct answer.
Recommended Posts