Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
How many days would be holidays
if we respect the birthdays of all the past emperors?
Hajime Nanjo, Nobuhiro Shimizu, Taku Yamanaka
2017-12-28
Kuno and Yamanaka Groups
End-of-the Year Presentation
Introduction
• 125 emperors in Japan in the past
• Birthdays of 3 emperors are holidays
• Meiji Emperor : Nov. 3, Culture Day
• Showa Emperor : Apr. 29, Showa Day
• Current Emperor : Dec. 23, The Emperor’s Birthday
2
Question• If we make the birthdays of
all the past 125 emperors as holidays, how many “Emperor’s birthday” holidays will we have?
• N = 365 (#days/year)
• M = 125 (#emperors)
• n : #holidays
3
1. Brute-force method• Split emperors into multiple days
• Example: 7 emperors
4
Day A Day A B Day A B
(7) (1+6) (2+5)
1 day 2 days 2 days
Day A B C D
(1+2+2+2)
4 days
. . .
Example: #cases for the splitting pattern
• 365C1 : pick 1 day
• × 7C1 : pick 1 emperor
• × 365-1C3 : pick 3 days
• × 7-1C2x3 : pick 2x3 emperors
• ×(2x3)! : Line up emperors
• × 1/(2!)3 : Remove double-counts5
Day A B C D
(1+2+2+2)
4 days
= 1,833,153,121,800
6
#holidays 1 2 3 4 5 6 7
partitions (7) (1+6) (1+1+5) (1+1+1+4) (1+1+1+1+3) (1+1+1+1+1+2) (1+1+1+1+1+1+1)
(2+5) (1+2+4) (1+1+2+3) (1+1+1+2+2)
(3+4) (1+3+3) (1+2+2+2)
(2+2+3)
#cases 365 837018 1.45E+10 6.11E+12 8.82E+14 4.76E+16 8.15E+17
#holidays
Prob
abili
ty
× 1 / 365 7
Partition Number (分割数) = 15
71
Problem of Partition No.
• It is LARGE!
• Took 100 min for M=90.
• Expect 80 hours for M=125
7N
Part
ition
Num
ber
100
109
0 100
2. Monte Carlo Method• Monte Carlo method can be
used to calculate the expected number of holidays
• M emperors are uniformly assigned to 365 boxes.
8
M
Jan. 1st
Dec. 31st
hol hol hol hol ß Number of holidays is immediately obtained.
…
…
N h
isto
ries
More realistic distribution
†http://www.mhlw.go.jp/toukei/saikin/hw/jinkou/tokusyu/syussyo-4/syussyo1-2.html
Japanese government provides the statistic information of fraction of birth-month.
†
1 3 5 7 9 11
fract
ion
The real distribution is NOT uniform at all!
The assignment of birth days is weighted
according to this fraction.
DecSep…Jan
Expected number of holidays decreases by only 0.03 days (43 minutes). à Relax! Still we can take sufficient number of holidays
even in this realistic situation.
N h
isto
ries
3. Recurrence Formula• Q(M | n) : The number of cases for distributing M emperors
to n specific days
• Probability that M emperors fit in n days out of N days in a year
• Used Python (infinite #digits for integers!)12
となる。ただし、差し引く日数の最大値は n− 1とM のうち小さい方であるため、
Q(M |n) = nM −min(M,n−1)∑
i=1
nCi Q(M |i) (2)
と表せる。次に、1年N 日のうち、n日にM 人が入る確率は
P (M,N |n) = NCnQ(M |n)NM
(3)
である。したがって、漸化式の式 (2)を用いて i ≤ M についてQ(M |i)を求めておけば、祝日の日数の確率分布 P (M,N |n)が計算できる。
3.2 漸化式の計算Q(M |i)は整数であるので正確に計算できるが、NM = 365125 ≃ 10320 という大きな数を扱う。そこで、整数の桁数に制限のない Pythonを用いて計算した。P (M,N |n)の計算では実数で割り算するために、割る数と割られる数 (整数)を、Pythonで表せる実数O(10308)の範囲に収まるまで 10100(整数)で約分した。図 2に、漸化式で求めた天皇誕生日の日数の確率分布 P (125, 365|n)を示す。期待値は
106.0日であり、分布のRMSは 3.5日である。この結果は、*****の方法で計算して求めた結果と一致する。
図 2: 漸化式を用いた、天皇誕生日の日数の確率分布。
3
all in 1 day all in 2 daysQ(M |n) = nM � nC1 Q(M |1)� nC2 Q(M |2) · · ·
= nM �min(M,n�1)X
i=1
nCi Q(M |i)
Result of recurrence formula
13n (#holidays)
Prob
abili
ty
0 100 0
0.1
M = 125 emperors = 106.0 days RMS = 3.5 days
14n (#holidays)
Prob
abili
ty
0 100
10-11
10-186
Result of recurrence formula
4. Simple calculation
15
M-1
N-1i
j
Emperor ID
Day0 1 2 3012
× × ⚪ ×× × × ×× × × ×
… ×××
×× × × ×
……
…
Pholiday
= 1� (1� 1/N)MPworkday
= (1� 1/N)M
N(365) patterns/row
Result of simple calculation
• Binomial distribution : N,Pholiday → P(n)
• Mean = N x Pholiday = 365 x (1-(1-1/365)125 )=106 days
• RMS = √ NPholiday(1-Pholiday) = 8.7 days
16
Comparisons
17
formulaMC
• Recurrence formula and the simple formula agree up to 12 digits. But why
• MC is consistent with the recurrence formula
MC-formula
M
X
n
n · NCnQ(M |n)/NM = N⇥1� (1� 1/N)M
⇤?
0 1000
0.04
300
RMS Comparisons• RMS of the simple formula does not agree
18
formulaMC
+ simple
M
RM
S
0 10000
8
Conclusion• #holidays =
106.0 ± 3.5 days (for 125 emperors)
• Probability distribution function =
• RMS needs the recurrence formula or MC
19
N⇥1� (1� 1/N)M
⇤
0 50 100 150 200 250 300 3500
5000
10000
15000
20000
25000
Number of holidays
Mean:46.7837
RMS :1.63511
Mean:105.953
RMS :3.4784
Mean:154.141
RMS :4.70842
Mean:204.701
RMS :5.6498
Mean:272.409
RMS :6.0882
M=50
M=125
M=200
M=300
M=500
Number of holidays
図 4: 実際の誕生月の割合を考慮して,シミュレーションした祝日の数の分布。赤 (M = 50),黒 (M = 125) ,マゼンタ (M = 200),青 (M = 300),緑 (M = 500)
認識できる。
4 漸化式を用いた方法4.1 漸化式の導出次に、漸化式を用いた方法を考える。Q(M |n)を、ある特定の n日にM 人を分配する
場合の数とする。M 人それぞれが n通り選ぶ選び方は nM 通りあるが、これはM 人全員が 1日に集中してしまう場合や、2日間に集中してしまう場合などを含む。したがってそれらの寄与を差し引くと、
Q(M |n) = nM − nC1 Q(M |1)− nC2 Q(M |2)− · · · (1)
となる。ただし、差し引く日数の最大値は n− 1とM のうち小さい方であるため、
Q(M |n) = nM −min(M,n−1)∑
i=1
nCi Q(M |i) (2)
と表せる。このQ(M |n)を用いると、1年N 日のうち、n日にM 人が入る確率は
P (M,N |n) = NCnQ(M |n)NM
(3)
である。したがって、漸化式の式 (2)を用いてQ(M |i)を i = 1からM まで順に求めておけば、祝日の日数の確率分布 P (M,N |n)を計算できる。
5
0 50 100 150 200 250 300 3500
5000
10000
15000
20000
25000
Number of holidays
Mean:46.7837
RMS :1.63511
Mean:105.953
RMS :3.4784
Mean:154.141
RMS :4.70842
Mean:204.701
RMS :5.6498
Mean:272.409
RMS :6.0882
M=50
M=125
M=200
M=300
M=500
Number of holidays
図 4: 実際の誕生月の割合を考慮して,シミュレーションした祝日の数の分布。赤 (M = 50),黒 (M = 125) ,マゼンタ (M = 200),青 (M = 300),緑 (M = 500)
認識できる。
4 漸化式を用いた方法4.1 漸化式の導出次に、漸化式を用いた方法を考える。Q(M |n)を、ある特定の n日にM 人を分配する
場合の数とする。M 人それぞれが n通り選ぶ選び方は nM 通りあるが、これはM 人全員が 1日に集中してしまう場合や、2日間に集中してしまう場合などを含む。したがってそれらの寄与を差し引くと、
Q(M |n) = nM − nC1 Q(M |1)− nC2 Q(M |2)− · · · (1)
となる。ただし、差し引く日数の最大値は n− 1とM のうち小さい方であるため、
Q(M |n) = nM −min(M,n−1)∑
i=1
nCi Q(M |i) (2)
と表せる。このQ(M |n)を用いると、1年N 日のうち、n日にM 人が入る確率は
P (M,N |n) = NCnQ(M |n)NM
(3)
である。したがって、漸化式の式 (2)を用いてQ(M |i)を i = 1からM まで順に求めておけば、祝日の日数の確率分布 P (M,N |n)を計算できる。
5
Conclusion
• Depending on how you approach/think, the problem can be
• extremely difficult and time consuming, or
• extremely simple and quick
• Monte Carlo is easy and robust
• Writeup 「全ての天皇の誕生日を祝日にすると何日休みになるか」is available on the program page
20
Happy Holidays!
21
Backup
22
Check with data
• M = 138 members
• n = 114 different birthdays
• expected n = 115.0 ± 3.7
23
入山 杏奈Anna Iriyama
1995.12.03AKB48 Team A
大家 志津香Shizuka Oya
1991.12.28AKB48 Team A
小嶋 菜月Natsuki Kojima
1995.03.08AKB48 Team A
佐々木 優佳里Yukari Sasaki
1995.08.28AKB48 Team A
白間 美瑠Miru Shiroma
1997.10.14AKB48 Team A /NMB48 Team M
田北 香世子Kayoko Takita
1997.02.13AKB48 Team A
谷口 めぐMegu Taniguchi
1998.11.12AKB48 Team A
中西 智代梨Chiyori Nakanishi
1995.05.12AKB48 Team A
樋渡 結依Yui Hiwatashi
2000.04.30AKB48 Team A
宮崎 美穂Miho Miyazaki
1993.07.30AKB48 Team A
宮脇 咲良Sakura Miyawaki
1998.03.19AKB48 Team A /
HKT48 Team K IV
横山 由依Yui Yokoyama
1992.12.08AKB48 Team A
市川 愛美Manami Ichikawa
1999.08.26AKB48 Team K
久保 怜音Satone Kubo
2003.11.20AKB48 Team K
兒玉 遥Haruka Kodama
1996.09.19AKB48 Team K /HKT48 Team H
篠崎 彩奈Ayana Shinozaki
1996.01.08AKB48 Team K
Select LanguageChinese Japanese
MemberMember ScheduleSchedule GoodsGoods TicketTicket AKB48 TheaterAKB48 Theater DiscographyDiscography Official mobileOfficial mobile Fan clubFan club Handshake eventHandshake event BlogBlog
TOP > Member
Display all members
Narrow your search
Input a member name
Team A
Team K
Team B
Team 4
Team 8
研究生
Date of birth
「レッツゴー研究生!」公演「レッツゴー研究生!」公演「レッツゴー研究生!」公演「レッツゴー研究生!」公演
2017年12月24日(日)
How to apply for tickets
AKB48 Group ID PasswordWeb member registration
View this page in: English Translate Turn off for: Japanese Options ▼
入山 杏奈Anna Iriyama
1995.12.03AKB48 Team A
大家 志津香Shizuka Oya
1991.12.28AKB48 Team A
小嶋 菜月Natsuki Kojima
1995.03.08AKB48 Team A
佐々木 優佳里Yukari Sasaki
1995.08.28AKB48 Team A
白間 美瑠Miru Shiroma
1997.10.14AKB48 Team A /NMB48 Team M
田北 香世子Kayoko Takita
1997.02.13AKB48 Team A
谷口 めぐMegu Taniguchi
1998.11.12AKB48 Team A
中西 智代梨Chiyori Nakanishi
1995.05.12AKB48 Team A
樋渡 結依Yui Hiwatashi
2000.04.30AKB48 Team A
宮崎 美穂Miho Miyazaki
1993.07.30AKB48 Team A
宮脇 咲良Sakura Miyawaki
1998.03.19AKB48 Team A /
HKT48 Team K IV
横山 由依Yui Yokoyama
1992.12.08AKB48 Team A
市川 愛美Manami Ichikawa
1999.08.26AKB48 Team K
久保 怜音Satone Kubo
2003.11.20AKB48 Team K
兒玉 遥Haruka Kodama
1996.09.19AKB48 Team K /HKT48 Team H
篠崎 彩奈Ayana Shinozaki
1996.01.08AKB48 Team K
Select LanguageChinese Japanese
MemberMember ScheduleSchedule GoodsGoods TicketTicket AKB48 TheaterAKB48 Theater DiscographyDiscography Official mobileOfficial mobile Fan clubFan club Handshake eventHandshake event BlogBlog
TOP > Member
Display all members
Narrow your search
Input a member name
Team A
Team K
Team B
Team 4
Team 8
研究生
Date of birth
「レッツゴー研究生!」公演「レッツゴー研究生!」公演「レッツゴー研究生!」公演「レッツゴー研究生!」公演
2017年12月24日(日)
How to apply for tickets
AKB48 Group ID PasswordWeb member registration
View this page in: English Translate Turn off for: Japanese Options ▼
https://www.akb48.co.jp/about/members/
http://oshitan.com/akb48/
Check with data
24
AKB48
NMB48, SKE48
Nogizaka46HKT48
HelloPro
golf players Takarazukaboat racers
jurists translatorsjockeys
tennis playersmovie directors
actors/actressesbaseball players
politicians
http://zukaholic.3album.net/student/index/S_birthday/
http://oshitan.com
https://www.tanjoubi.org/birth/
medical scholarswrestling
sumo, basketball, boxing, volleyball
M
n (d
ays)
100
400
40102 103 104
25
RMS
Differences between data and calculations
M102 103 104
n (d
ata
- exp
ecte
d)
0
5
-5
5. Discussion• Expected number of holidays
• Why exponential??
26
4 考察***節で求めた、天皇誕生日の日数の期待値 ⟨n⟩をN ≫ 1で近似すると
⟨n⟩ = N[1−
(1− 1
N
)M](4)
= N
[1−
(1− 1
N
)N MN]
(5)
≃ N[1− exp
(−MN
)](6)
と簡単な形になる。これはどこかで見た形である。ある1日に着目した場合、その日が誕生日である天皇の数の期待値は
µ = M/N (7)
である。ポアッソン分布を仮定すると、その日が誕生日である天皇が1人以上いる確率は
1− P (µ, 0) = 1− e−µµ0
0!(8)
= 1− exp(−MN
)(9)
である。1年はN 日であるので、天皇誕生日の日数の期待値は上の確率にN をかけて
N
[1− exp
(−MN
)](10)
となり、式 (6)と一致する。図 3に、式****で求めた天皇誕生日の日数の期待値と、ポアッソン分布を仮定した
場合と正確な値の比を、天皇の人数の関数として表す。このように、天皇の人数によらず、ポアッソン分布を仮定して求めた値は 0.2%以内で正確な値と一致する。
4
(if N>>1)
Actually, …• For 1 specific day, the expected number of emperors
whose birthday is that day
• Probability that some emperor’s birthday is on that day, with Poisson distribution
• Expected number of birthdays in a year with N days
27
µ = M/N(= 125/365)
1� P (µ, 0) = 1� e�µµ0
0!= 1� e�µ
N⇣1� e�M/N
⌘
How to count birthdays• Example: Download
https://www.tanjoubi.org/birth/bunrui_076.html to 076_1.txt,
076_2,txt, …
・1902年01月22日 田畑忍 (たばた しのぶ)
・1902年08月21日 石本雅男 (いしもと まさお)
• cat 076_*.txt | tr '・' '\n' (split to lines)
1902年01月22日 田畑忍
(たばた しのぶ)
1902年08月21日 石本雅男 (いしもと まさお)
• cat 076_*.txt | tr '・' '\n' | grep 14px | sed 's/\
29
• cat 076_*.txt | tr '・' '\n' | grep 14px | sed 's/\