How many days would be holidays if we respect the birthdays of all - - PowerPoint PPT Presentation

how many days would be holidays if we respect the
SMART_READER_LITE
LIVE PREVIEW

How many days would be holidays if we respect the birthdays of all - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

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

slide-3
SLIDE 3

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

slide-4
SLIDE 4
  • 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 . . .

slide-5
SLIDE 5

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-counts

5

Day A B C D (1+2+2+2) 4 days

= 1,833,153,121,800

slide-6
SLIDE 6

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 Probability × 1 / 365 7

Partition Number (分割数) = 15

7 1

slide-7
SLIDE 7

Problem of Partition No.

  • It is LARGE!
  • Took 100 min for

M=90.

  • Expect 80 hours

for M=125

7

N Partition Number 100 109 100

slide-8
SLIDE 8
  • 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. … …

slide-9
SLIDE 9

N histories

slide-10
SLIDE 10

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

fraction

The real distribution is NOT uniform at all!

The assignment of birth days is weighted according to this fraction.

Dec Sep

Jan

slide-11
SLIDE 11

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 histories

slide-12
SLIDE 12
  • 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

となる。ただし、差し引く日数の最大値は と のうち小さい方であるため、 と表せる。 次に、1年 日のうち、 日に 人が入る確率は

P(M, N|n) =

NCn

Q(M|n) NM

である。したがって、漸化式の式 を用いて について を求めておけば、 祝日の日数の確率分布 が計算できる。

漸化式の計算

は整数であるので正確に計算できるが、 という大きな 数を扱う。そこで、整数の桁数に制限のない を用いて計算した。 の 計算では実数で割り算するために、割る数と割られる数 整数 を、 で表せる実数 の範囲に収まるまで 整数 で約分した。 図 に、漸化式で求めた天皇誕生日の日数の確率分布 を示す。期待値は 日であり、分布の は 日である。この結果は、*****の方法で計算して 求めた結果と一致する。 図 漸化式を用いた、天皇誕生日の日数の確率分布。

all in 1 day all in 2 days

Q(M|n) = nM − nC1 Q(M|1) − nC2 Q(M|2) · · · = nM −

min(M,n−1)

X

i=1 nCi Q(M|i)

slide-13
SLIDE 13

Result of recurrence formula

13

n (#holidays) Probability 100 0.1 M = 125 emperors <n> = 106.0 days RMS = 3.5 days

slide-14
SLIDE 14

14

n (#holidays) Probability 100 10-11 10-186

Result of recurrence formula

slide-15
SLIDE 15
  • 4. Simple calculation

15

M-1 N-1 i j Emperor ID Day 0 1 2 3 1 2 × × ⚪ × × × × × × × × × … × × × × × × × × … … …

Pholiday = 1 − (1 − 1/N)M

Pworkday = (1 − 1/N)M

N(365) patterns/row

slide-16
SLIDE 16

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

slide-17
SLIDE 17

<n> Comparisons

17

formula MC

  • Recurrence formula and the simple formula agree up to 12 digits.

But why

  • MC is consistent with the recurrence formula

<n> MC-formula

M

X

n

n · NCnQ(M|n)/N M = N ⇥ 1 − (1 − 1/N)M⇤ ?

1000 0.04 300

slide-18
SLIDE 18

RMS Comparisons

  • RMS of the simple formula does not agree

18

formula MC

+

simple

M RMS 1000 8

slide-19
SLIDE 19

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⇤

図 実際の誕生月の割合を考慮して, シミュレーションした祝日の数の分布。 赤 , 黒 ,マゼンタ ,青 ,緑 認識できる。

漸化式を用いた方法

漸化式の導出

次に、漸化式を用いた方法を考える。 を、ある特定の 日に 人を分配する 場合の数とする。 人それぞれが 通り選ぶ選び方は 通りあるが、これは 人全員 が 日に集中してしまう場合や、 日間に集中してしまう場合などを含む。したがってそ れらの寄与を差し引くと、 となる。ただし、差し引く日数の最大値は と のうち小さい方であるため、 と表せる。 この を用いると、1年 日のうち、 日に 人が入る確率は

P(M, N|n) =

NCn

Q(M|n) NM

である。したがって、漸化式の式 を用いて を から まで順に求めてお けば、祝日の日数の確率分布 を計算できる。

図 実際の誕生月の割合を考慮して, シミュレーションした祝日の数の分布。 赤 , 黒 ,マゼンタ ,青 ,緑 認識できる。

漸化式を用いた方法

漸化式の導出

次に、漸化式を用いた方法を考える。 を、ある特定の 日に 人を分配する 場合の数とする。 人それぞれが 通り選ぶ選び方は 通りあるが、これは 人全員 が 日に集中してしまう場合や、 日間に集中してしまう場合などを含む。したがってそ れらの寄与を差し引くと、 となる。ただし、差し引く日数の最大値は と のうち小さい方であるため、

Q(M|n) = nM −

min(M,n−1)

  • i=1

nCi Q(M|i)

と表せる。 この を用いると、1年 日のうち、 日に 人が入る確率は である。したがって、漸化式の式 を用いて を から まで順に求めてお けば、祝日の日数の確率分布 を計算できる。

slide-20
SLIDE 20

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

slide-21
SLIDE 21

Happy Holidays!

21

slide-22
SLIDE 22

Backup

22

slide-23
SLIDE 23

Check with data

  • M = 138 members
  • n = 114 different birthdays
  • expected n = 115.0 ± 3.7

23

入山 杏奈 Anna Iriyama 1995.12.03 AKB48 Team A 大家 志津香 Shizuka Oya 1991.12.28 AKB48 Team A 小嶋 菜月 Natsuki Kojima 1995.03.08 AKB48 Team A 佐々木 優佳里 Yukari Sasaki 1995.08.28 AKB48 Team A 白間 美瑠 Miru Shiroma 1997.10.14 AKB48 Team A / NMB48 Team M 田北 香世子 Kayoko Takita 1997.02.13 AKB48 Team A 谷口 めぐ Megu Taniguchi 1998.11.12 AKB48 Team A 中西 智代梨 Chiyori Nakanishi 1995.05.12 AKB48 Team A 樋渡 結依 Yui Hiwatashi 2000.04.30 AKB48 Team A 宮崎 美穂 Miho Miyazaki 1993.07.30 AKB48 Team A 宮脇 咲良 Sakura Miyawaki 1998.03.19 AKB48 Team A / HKT48 Team K IV 横山 由依 Yui Yokoyama 1992.12.08 AKB48 Team A 市川 愛美 Manami Ichikawa 1999.08.26 AKB48 Team K 久保 怜音 Satone Kubo 2003.11.20 AKB48 Team K 兒玉 遥 Haruka Kodama 1996.09.19 AKB48 Team K / HKT48 Team H 篠崎 彩奈 Ayana Shinozaki 1996.01.08 AKB48 Team K 研究生 「レッツゴー研究生!」公演 「レッツゴー研究生!」公演 「レッツゴー研究生!」公演 「レッツゴー研究生!」公演 年 月 日 日

入山 杏奈 大家 志津香 小嶋 菜月 佐々木 優佳里 白間 美瑠 田北 香世子 谷口 めぐ 中西 智代梨 樋渡 結依 宮崎 美穂 宮脇 咲良 横山 由依 市川 愛美 久保 怜音 兒玉 遥 篠崎 彩奈

研究生

「レッツゴー研究生!」公演 「レッツゴー研究生!」公演 「レッツゴー研究生!」公演 「レッツゴー研究生!」公演

年 月 日 日

https://www.akb48.co.jp/about/members/

http://oshitan.com/akb48/

slide-24
SLIDE 24

Check with data

24

AKB48 NMB48, SKE48 Nogizaka46 HKT48 HelloPro golf players Takarazuka boat racers jurists translators jockeys tennis players movie directors actors/actresses baseball players politicians

http://zukaholic.3album.net/student/index/S_birthday/ http://oshitan.com https://www.tanjoubi.org/birth/

medical scholars wrestling sumo, basketball, boxing, volleyball

M n (days) 100 400 40 102 103 104

slide-25
SLIDE 25

25

RMS

Differences between data and calculations

M 102 103 104 n (data - expected) 5

  • 5
slide-26
SLIDE 26
  • 5. Discussion
  • Expected number of holidays
  • Why exponential??

26

考察

***節で求めた、天皇誕生日の日数の期待値 を で近似すると

⟨n⟩ = N

  • 1 −
  • 1 − 1

N M = N

  • 1 −
  • 1 − 1

N N M

N

N

  • 1 − exp
  • −M

N

  • と簡単な形になる。これはどこかで見た形である。

ある1日に着目した場合、その日が誕生日である天皇の数の期待値は である。ポアッソン分布を仮定すると、その日が誕生日である天皇が1人以上いる確率は である。 年は 日であるので、天皇誕生日の日数の期待値は上の確率に をかけて となり、式 と一致する。 図 に、式****で求めた天皇誕生日の日数の期待値と、ポアッソン分布を仮定した 場合と正確な値の比を、天皇の人数の関数として表す。このように、天皇の人数によらず、 ポアッソン分布を仮定して求めた値は 以内で正確な値と一致する。

(if N>>1)

slide-27
SLIDE 27

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⌘

slide-28
SLIDE 28

How to count birthdays

  • Example: Download 


https://www.tanjoubi.org/birth/bunrui_076.html to 076_1.txt, 076_2,txt, …


・<span style="font-size:14px">1902年01月22日 <a href="https://www.tanjoubi.org/detail.php?no=92341">田畑忍</a></span> <span style="color:green;" class="pc">(たばた しのぶ)</span> <img src="../images/death.gif" title="この方は亡くなられています。"/><br />・<span style="font-size:14px">1902年08月21日 <a href="https://www.tanjoubi.org/detail.php?no=92604">石本雅男</a></span> <span style="color:green;" class="pc">(いしもと まさお)</span> <img src="../images/
 death.gif" title="この方は亡くなられています。"/><br />

  • cat 076_*.txt | tr '・' '\n' (split to lines)


<span style="font-size:14px">1902年01月22日 <a href="https://www.tanjoubi.org/detail.php?no=92341">田畑忍</a></span> <span style="color:green;" class="pc">(たばた しのぶ)</span> <img src="../images/death.gif" title="この方は亡くなられています。"/><br /> <span style="font-size:14px">1902年08月21日 <a href="https://www.tanjoubi.org/detail.php?no=92604">石本雅男</a></ span> <span style="color:green;" class="pc">(いしもと まさお)</span> <img src="../images/death.gif" title="この方は亡く なられています。"/><br />

  • cat 076_*.txt | tr '・' '\n' | grep 14px | sed 's/\<a href.*//' |

sed ’s/.*\>//' | grep 日 | sed 's/.*年//'


01月22日 08月21日

28

slide-29
SLIDE 29

29

  • cat 076_*.txt | tr '・' '\n' | grep 14px | sed 's/\<a href.*//' | sed

’s/.*\>//' | grep 日 | sed ’s/.*年//' | wc -l
 Count the number of lines
 482

  • cat 076_*.txt | tr '・' '\n' | grep 14px | sed 's/\<a href.*//' | sed

’s/.*\>//' | grep 日 | sed ’s/.*年//' | sort -u | wc -l
 Count the number of lines after removing duplicate lines
 275