Sunday, October 30, 2011

Movie tickets problem

/* You have two movie tickets and want to invite a friend to watch movie
together. You can invite several friends simultaneously. Each one of them
independently has probability p to accept your invitation. How many friends
should you invite to maximize the probability that exactly one friend
accepts your invitation?*/

Suppose we invite n persons.
P=n*(1-p)^(n-1)*p   //independently, sum
f(n)=ln(P)=ln(n)+(n-1)ln(1-p)+ln(p)   //log
df/dn=1/n + ln(1-p) = 0   //derivative to get local max,
n = -1/ln(1-p) = 1/p;  when x-->0,  -ln(1-x) = x+x^2/2 + x^3/3 + ...

No comments: