Skip to content

Simulates birthday problem with montecarlo simulation

License

Notifications You must be signed in to change notification settings

fvalle1/birthday

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graph

Birthday problem with montecarlo

Build Status MIT license

Simulates birthday problem with monte carlo simulation.

More informations about the problem here.

compile and run

compile: make

run: ./birthday.out

if you compile without makefile put the -O3 flags, it drastically reduces time of esecutions!

how it works

ExpeimentI generates n=500000 groups of people with random birthday during a year, then checks how may groups have got almost two people born in the same day.

ExperimentII still call people with random birthday until two have the same, it does it n=500000 times then tells the average number of people needed.

You can check that for about 23 people the probability of find two people with same birthday is near 50%!

random

this program uses a special yearrand() function, which returns a random integer based on real data provided by italian statistic institute.

source (date of born in Italy in 2014): http://demo.istat.it/altridati/IscrittiNascita/

I did this (you can do the same):

  • got data from here
  • fit the data with a polinomial (grade 3) function
  • generate random number between 1 and 365 based on that distribution

license

The MIT License (MIT) 2016 fvalle1

See LICENSE

About

Simulates birthday problem with montecarlo simulation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published