PDA

View Full Version : Birthday code? help needed



Ajaman
04-19-2012, 05:58 AM
Hi i am trying to write a code but have no idear how to do it..

can some one please help me with it

i am trying to give a random group of 23 people birthday dates and how likely is it that two people have the same birthday i need to write a program that will create the person array or ranging 1 to 23 and assign to each of the 23 people a random date for there "birthday" and expanding it by repeating it 100 times counting how many groups of 23 persons have at least one watching birthday the answer needs to be around 50%

thanks
i am really stuck and have no idear what to do
this is what i have so far

Private Sub Document_Open()
Randomise
End Sub

yea i basically no nothing

if some one can help me i would be happy to throw a few dollars there way

Frosty
04-19-2012, 09:00 AM
Why do you want to start in Word when what you're doing is a statistical analysis on numbers? I could get you a bit further in creating the array of people and random dates as birthdays, and then expanding that loop multiple times is trivial. But I'm not sure what the rest of your statement means. "One watching birthday the answer needs to be around 50%" -- Punctuation may help, but you pretty much lost me on that. I'm assuming you want some kind of result out of a random function? That may be, theoretically speaking, kind of tough.

But be that as it may... the VBA between Excel and Word for simply creating an array and populating it could be the same, but I would actually start in the Excel forum, unless there is some compelling reason for your output to be in Word format. There may be some functionality natively available in Excel regarding number analysis which isn't as easily available in Word.

I don't have a really deep knowledge of Excel formulas off the top of my head, but there are some who do. I'd cross-post this in the Excel forum here, include a link here (following typical cross-post etiquette)... and then re-ask the question.

Paul_Hossler
04-20-2012, 08:09 PM
This is a pretty common homework-type problem in probablity

http://en.wikipedia.org/wiki/Birthday_problem

Not saying that the OP is looking for homework help, but the link explains in a lot of detail

Paul

fumei
04-20-2012, 09:58 PM
LOL! If the OP is looking for a homework solution, the link should move them along quite nicely.

I quite agree that this is not a Word thing. This is an Excel thing.