Birthday Problem

S

Sandra

Well, it seems your work is cut out for you, unless the context of the
problem formulation is such that it really means something more than stated.

All your program has to do is to ask you whether your birthday is February
29th, and then apply the formula inconsiderately given you by Robert
E. Tisdale and at least one more poster. The program could output one
result based on the current year or on assuming a non leap-year, or it could
output two result, one for non-leap and one for leap-year. In the latter case
the formula should be suitably modified for leap year. Of course it could
also output four results, one for each combination of February 29th or not and
leap year or not. That way you could avoid the input part.

Also, it might be possible to avoid the leap year thing by analyzing whether
it can affect the result or not.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Thanks Alf - I am working on an encyrption\decryption program right
now so I think I am going to let this one go. I really am stuck :)

He is going to give us the answer on Wed - Do you want to see what he
comes up with ?

Sandra
 
H

Howard

David Harmon said:
On Mon, 12 Apr 2004 17:13:27 +0000 (UTC) in comp.lang.c++, Christopher


I am sure it cannot be correct to give Feb 29 the same weight as all the
other days. Which is the closer approximation, to do as above or to
ignore Feb 29 and calculate using 365?

Actually, the original question is unanswerable!

It would seem that there are four answers to the original question, one for
each of the following conditions:

1) Not a leap year, my birthday not on Feb. 29th.
2) Leap year, my birthday not on Feb. 29th.
3) Not a leap year, my birthday on Feb. 29th.
4) Leap year, my birthday on Feb. 29th.

We would need to handle "my birthday on Feb. 29th" differently from "my
birthday not on Feb. 29th", because the odds of someone ELSE having that
birthday are not the same as them having any other specific birthday. And
we'd have to handle the fact that it's leap year NOW because of the
differing number of days in the year.

However...

Even that is not accurate, because there is a basic assumption that the
distribution of birthdays across the year is uniform, and that is not a
provable assumption! (It may in fact be a false assumption, but I wouldn't
know how prove *that*, one way or the other.)

I *do* know that, for any given population, the distribution of birthdays is
not uniformly distributed. Look it up. If I recall, in temperate climates
there tend to be more births around the end of summer, presumably because as
it gets cold outside, people tend to, shall we say, "come together" more,
for the sake of warmth. And so, nine months later, there are more births.

So, if you live in a temperate climate, your birthday is in September, the
odds are greater that someone in a given set of people will have that
birthday than if your birthday is in, say April (where conception would have
occurred in July).

Of course, the instructor may have assumed a uniform distribution, and
intended to ignore leap year and a Feb. 29th birthday altogether. But,
being the nuisance I am, I'd have gone to the teacher and asked. :)

-Howard
 
S

Sandra

Actually, the original question is unanswerable!

It would seem that there are four answers to the original question, one for
each of the following conditions:

1) Not a leap year, my birthday not on Feb. 29th.
2) Leap year, my birthday not on Feb. 29th.
3) Not a leap year, my birthday on Feb. 29th.
4) Leap year, my birthday on Feb. 29th.

We would need to handle "my birthday on Feb. 29th" differently from "my
birthday not on Feb. 29th", because the odds of someone ELSE having that
birthday are not the same as them having any other specific birthday. And
we'd have to handle the fact that it's leap year NOW because of the
differing number of days in the year.

However...

Even that is not accurate, because there is a basic assumption that the
distribution of birthdays across the year is uniform, and that is not a
provable assumption! (It may in fact be a false assumption, but I wouldn't
know how prove *that*, one way or the other.)

I *do* know that, for any given population, the distribution of birthdays is
not uniformly distributed. Look it up. If I recall, in temperate climates
there tend to be more births around the end of summer, presumably because as
it gets cold outside, people tend to, shall we say, "come together" more,
for the sake of warmth. And so, nine months later, there are more births.

So, if you live in a temperate climate, your birthday is in September, the
odds are greater that someone in a given set of people will have that
birthday than if your birthday is in, say April (where conception would have
occurred in July).

Of course, the instructor may have assumed a uniform distribution, and
intended to ignore leap year and a Feb. 29th birthday altogether. But,
being the nuisance I am, I'd have gone to the teacher and asked. :)

-Howard
Thanks Howard ~ I did ask him, he is not giving any clues except that
the number is exact and is between 1600-1700

I did not think there could be an exact answer either - just an
approximation

I guess I'll find out later this week - I will let you guys know what
he came up with

Sandra
 
C

Christopher Benson-Manica

Sandra said:
Thanks Howard ~ I did ask him, he is not giving any clues except that
the number is exact and is between 1600-1700

Well, at least Alfred's contention that I gave you the answer is
clearly wrong in that case ;)
I guess I'll find out later this week - I will let you guys know what
he came up with

Sounds like it has a definite trick question element to it.
 
C

Christopher Benson-Manica

Sandra said:
He is going to give us the answer on Wed - Do you want to see what he
comes up with ?

Given the level of discussion, I doubt he'd be the only one :)
 
S

Sandra

Well, at least Alfred's contention that I gave you the answer is
clearly wrong in that case ;)


Sounds like it has a definite trick question element to it.



I will let you guys know :)
 
G

Gary Labowitz

Sandra said:
Thanks Alf - I am working on an encyrption\decryption program right
now so I think I am going to let this one go. I really am stuck :)

He is going to give us the answer on Wed - Do you want to see what he
comes up with ?

You bet. Especially since you cannot know, without some distribution
information, how many people it will take to find your birthday.
If you were born on 1-1 and asked people as they got off the subway if
anyone was born on 1-1 there is no telling how many people you would
ask before one of them was born on 1-1. It's not the pigeon hole
principle here. You might go through 1,000,000 people until one was
born on 1-1. There is just no way of telling.
If, on the other hand, you were asking people what their birthdates
were and kept track of the answers, you might be surprised to find
that after the first 20 you will have a 50-50 chance of finding two of
them with the same birthday. But it is a different problem.

I think your teacher is on a wrong track.
 
A

Alf P. Steinbach

* Christopher Benson-Manica said:
Well, at least Alfred's contention that I gave you the answer is
clearly wrong in that case ;)

The only meaningful numerical result is the one I gave first, and implied by
later posters. Sandra would not have learned less if you just gave that
number. What one should not do is to help someone avoid learning, or,
although clearly not the case here, to cheat.

Sounds like it has a definite trick question element to it.

I think so too. The range 1600-1700 means the seemingly only meaningful
result (for non Feb 29) is not the one intended. I'm leaning towards thinking
there is some earlier context -- earlier questions -- Sandra did not list.
 
T

tom_usenet

I was given this problem for extra credit and I am just stuck !
BTW - I am not asking for source code and I am not asking anyone to do
my homework as I do want to learn .. I just need a hint or two to get
moving and I need to know if what I have written so far is leading me
in the right direction ~

Ok - The problem is to find out how many people need to be in a room
for a 95% chance that someone in that room will match my birthday

This question is impossible to answer without statistics on how many
people in the population were born on each day of the year. It is very
unlikely to be a uniform distribution, which is what everyone else
seems to be assuming (e.g. if everyone in the world was born on 4th
July, the answer would be 1).

Even if you assume that anyone was born on a particular day of the
year with equal probability, you still run into the problem of leap
years. To calculate how this affects things will require a full world
population age distribution, to find out the average number of leap
years per year over the population as a whole. However, assuming
365.25 days per year is probably safe since you only need a result to
the nearest person.

Anyway, before answering the question, make sure you state your
assumptions clearly.

Tom
 
I

Ioannis Vranos

Sandra said:
I was given this problem for extra credit and I am just stuck !
BTW - I am not asking for source code and I am not asking anyone to do
my homework as I do want to learn .. I just need a hint or two to get
moving and I need to know if what I have written so far is leading me
in the right direction ~

Ok - The problem is to find out how many people need to be in a room
for a 95% chance that someone in that room will match my birthday



I do not think that the data you provided are enough. When you say birthday
you mean day and month and year? Is there any other restriction (e.g. is it
possible two people in the room to have the same birthday (day, month and
year) and still be different from yours?
 
C

Christopher Benson-Manica

Alf P. Steinbach said:
The only meaningful numerical result is the one I gave first, and implied by
later posters. Sandra would not have learned less if you just gave that
number. What one should not do is to help someone avoid learning, or,
although clearly not the case here, to cheat.

I certainly hope I did neither...
 
J

Julie

Sandra said:
Write a C Program that will determine how many people must be in a
room in order to insure a 95% chance there is somebody in that room
with your birthday.

Is that _birthday_ as in sharing a common day of the year

- or -

_birth_date_ as in sharing a common point in time (day, month, year)?
 
A

Anonymous

E. Robert Tisdale said:
Something that calls itself Anonymous wrote:

[snip]

This is an obvious troll. Please ignore it.

I actually find this offensive. I have never been called a troll before
and I don't understand why my post was considered one.
It was polite (no insults of any kind) and not only did it simply say
that this was not an appropriate place for the question but it also
suggested other groups where it would be more appropriate. I mean, while
any of us are capable of helping her with this problem, it was a math
problem that really didn't have anything to do with C++ or even programming!
Really, where is the C++ in "Ok - The problem is to find out how many
people need to be in a room for a 95% chance that someone in that room will
match my birthday?"
 
C

Christopher Benson-Manica

I actually find this offensive. I have never been called a troll before
and I don't understand why my post was considered one.

Most regulars of this group (and comp.lang.c) realize that E. Robert
Tisdale is a troll himself. His opinions on who is or is not a troll
are fairly irrelevant; please try not to take his trolls seriously or
personally.
 
M

Mabden

Julie said:
Is that _birthday_ as in sharing a common day of the year

- or -

_birth_date_ as in sharing a common point in time (day, month, year)?

It's an old logic puzzle. It refers to birthday - no year is implied.
You and I can share a birthday and be 20 years apart in age.


I think if you have 25 people the answer is something like a 50% chance.
By the time you have 70 people in a room it is about 100% - unless it's
a Twins convention! :)

Not what you thought, huh!


The way to get the actual number is to analyze what the probabilities
are. If I am in a room with just one person, then the chances of us
sharing a birthday are 1 in 365. Add another person and the probability
goes to 1 in 363. So, (364/365) x (363/365).

The complete table is an exercise for the student! ;-)
 
C

Christopher Benson-Manica

Mabden said:
The way to get the actual number is to analyze what the probabilities
are. If I am in a room with just one person, then the chances of us
sharing a birthday are 1 in 365. Add another person and the probability
goes to 1 in 363. So, (364/365) x (363/365).
The complete table is an exercise for the student! ;-)

Or an exercise for previous posts :) (It turns out that I was the one
who posted that code, and it also turns out that the professor is
looking for a vastly different answer.)
 
D

Dave Moore

This question is impossible to answer without statistics on how many
people in the population were born on each day of the year. It is very
unlikely to be a uniform distribution, which is what everyone else
seems to be assuming (e.g. if everyone in the world was born on 4th
July, the answer would be 1).

Interesting point ... in fact, in some areas, like say Minnesota or
North Dakota, birthdays tend to be clustered in the months July-Sept.

[ya' gotta find somethin' to do on those long, cold winter nights I
guess]

To extend this further, with technological advances in the last n
years (say 40 if you like), the "clustering" from the above example
has likely started to decrease with time, yielding a more even
distribution for people born more recently.

[Now you can drive in your heated automobile on plowed, paved roads
to, say, go bowling .. so there are more solutions to the
aforementioned "what to do" problem, regardless of the time of year
....]

So, you would really have to know quite a lot of details about the
people in the room (is it a geratrics convention in Alberta, or a
child's birthday party in Sao Paolo) in order to get an accurate grasp
on the probability problem.


Like some other posters in this thread, I wonder if the point of the
problem was really the code, or whether it was intended to help you
realize that sometimes the most simply stated problems are the
trickiest to solve. If I were the prof., I would give credit based
not so much on the code itself, but rather on how well the students
thought about the problem ... recognizing the leap-year issue gets one
point, the non-even birthday distribution gets two points, etc. After
all, a careful analysis of the problem is (at least) 80% of proper
program design .. I guess (from context) that your course is on an
introductory level, but one can never learn this lesson too early.

I am extremely interested to see the soln. given by your prof. ... if
only to find out how narrowly/broadly the problem was defined in her
mind. In my experience, profs, like wizards, can be quite subtyl ..
and they can even be quick to anger as well 8*).

Good luck!
 
D

Default User

Dave said:
Interesting point ... in fact, in some areas, like say Minnesota or
North Dakota, birthdays tend to be clustered in the months July-Sept.

[ya' gotta find somethin' to do on those long, cold winter nights I
guess]


Do you have statistics to back that up? Sounds pretty urban-legendy to
me, like the supposed baby booms following blackouts and 9/11 and such.



Brian Rodenborn
 
B

Bruce Clement

Default said:
Dave Moore wrote:

Interesting point ... in fact, in some areas, like say Minnesota or
North Dakota, birthdays tend to be clustered in the months July-Sept.

[ya' gotta find somethin' to do on those long, cold winter nights I
guess]




Do you have statistics to back that up? Sounds pretty urban-legendy to
me, like the supposed baby booms following blackouts and 9/11 and such.



Live birth totals for USA 1993 :

Month Per Vs daily
Total Day Avg

Jan 323,420 10,433 -4.91%
Feb 304,947 10,891 -0.73%
Mar 342,518 11,049 0.71%
Apr 327,372 10,912 -0.54%
May 336,368 10,851 -1.10%
Jun 335,703 11,190 +1.99%
Jul 352,949 11,385 +3.77%
Aug 351,306 11,332 +3.29%
Sep 348,399 11,613 +5.85%
Oct 333,313 10,752 -2.00%
Nov 316,751 10,558 -3.76%
Dec 331,477 10,693 -2.54%


Monthly totals from "Live births by state by month for 1993"
http://www.nber.org/natality/1993/docs/nat1393.txt

Interested people can repeat the calculations for individual states.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top