• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

probability

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Could anyone tell me how i could code a program to display the probability of 2 people in a group of about 300 sharing the same brithday?
i'm using the formulae: P(E) = 1 - P(none have same birthday)
Any ideas?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For starters, do you want the probability of at least two people sharing a birthday, or exactly two people sharing a birthday. The former is easier, using the formula you gave as a start. However the latter cannot be calculated using your formula, since it omits the possibility of 3 or more people sharing a birthday.
I'll assume it's the former you're interested in. Concentrate on calculating the probability no one has the same birthday. Pretend that there are 365 days in a year for now, and correct this later. Try to figure the chance that there are no shared birthdays, if there are only two people in the room. Then try to do it for three people - and then four. With luck you will see a pattern emerge. Enjoy...
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, be prepared for rounding errors. With 300 hundred people, the chances that at least two share a birthday is so close to 1, that the correct .9999... value may round off to exactly one at some point using floating point arithmetic.
 
reply
    Bookmark Topic Watch Topic
  • New Topic