Dimitriy V. Masterov <dvmaster@lily.src.uchicago.edu> asks:
> I would like to plot the probability that two people share a birthday as a
> function of the number of people in the room n. The formula is
> 1-product((366-i)/365,i,1,n)
> In TeX, it would be
> 1-\dprod\limits_{i=1}^{n}\frac{366-i}{365}.
> If I have a variable n={1,...,50}, how can I define the product within
> Stata? There does not seem to be math function that can do this.
The product is the exponentiated sum of the logs.
. clear
. set obs 100 // I assume that is enough, p(100) = .9999997
. gen i = _n
. gen p = 1-exp(sum(ln(366-i) - ln(365)))
--Bobby
P.S. The break-even point on a bet is n = 23 people.
--Bobby
rgutierrez@stata.com
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/