Re: Birthday Problem

From: Claudio Puviani (puviani_at_hotmail.com)
Date: 04/12/04


Date: Mon, 12 Apr 2004 15:52:58 GMT


"Sandra" <s.cantrell@mindspring.com> wrote
> 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 wrote a program that will calculate that percentage
> for any 2 bithdays to match, but that is not the same
> thing :)
>
> Here is what I have so far:
>
>
> #include "stdafx.h"
> #include <time.h>
> #include <iostream>
> using namespace std;
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> int sample[1000];
> int i=1,j=1;
> int a =0;
> srand( (unsigned)time( NULL ) );
>
> while (a != 325)
> { sample[i]=rand()%365+1;
> //cout<<" "<<sample[i];
> a = sample[i];
> i++;
> if (a==325) cout<<"\n\n\n Match "<<a<<" at "<<i<<"\n";
> }
>
> return 0;
>
> This puts random numbers from 1-365 in an
> array - reads the array and tries to detect an
> exact match The problem is that the match is
> so random - how do I come up with a 95%
> chance? Is there any exact answer ?
>
> As I said - just need some hints to move along..

This is a problem that should be solved analytically rather than with brute
force, unless you were specifically told to use brute force. If it's the
latter, consider a naive way to do it by hand: check the probability if the
group is of size 1. Then check if the group is of size 2. And so on, until
you hit 95%. There are more sophisticated ways to search that space, but
you're better off taking things one step at a time (no pun intended). Again,
if you have a choice, solve it analytically (any beginning text on
probabilities will have that very example).

Claudio Puviani



Relevant Pages

  • Re: Still too slow
    ... Consider if you know the sum s_low of the lower half of the array, and the sum s_high of the higher half of the array. ... Then you can choose the lower half with probability s_low/, ... often chosen a "blind" sort of literal implementation of the above will perhaps slow down the program instead of speeding it up, because it only speeds up those searches that progress beyond the first item. ...
    (comp.lang.python)
  • Re: [Help] Brute Force
    ... characters with ascii codes 32..126, you want to generate all possible strings consisting of characters with those codes, whose length is between some minimum and maximum? ... so it doesnt go into an array when its generated, cause that'll return a large arrays when you want to create large amounts of information. ... Anyways, since you are talking about brute force, I'd assume you know the decryption algorithm, a part or all of the encrypted data, possibly a piece of clear text, or a way to figure out that decrypted data resembles what might be clear text. ...
    (alt.php)
  • RE: A function to get a variable row reference for range in XNPV f
    ... Match can require an exact match or, ... You'll have to adjust it if your array ... >>> I want to use the formula below to calculate the NPV of a future stream of ... >>> NPV formula. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: draw random number from array
    ... Array q contains a series of guassian ... subroutine which will calculate the probability of an events occurance. ... finding the inverse function, there's not always an analytic solution. ... I suspect that there is a solution for a Gaussian distribution but I ...
    (comp.lang.fortran)
  • Re: To "hardware" RAID 5 or software RAID 5
    ... The probability of two simultaneous disk failures in an array that small are quite small. ... You'd have to back up your data, create a new RAID device, and restore. ...
    (Fedora)