How would I find the first Integer to satisfy equation?

140 Views Asked by At

During a test at school today the following question was asked - (Translated from Danish, please ask if the question is unclear)

At a workplace, consisting of 50 members, there is a 7% chance that a given worker is using the toilet at any time.

Assume every worker has the same chance of being at the toilet at any time, and that their toilet visits are all independent of one another

What is the minimum number of toilets required, such that the probability of a queue forming outside the toilet is less that 5%?

Is there an 'elegant' way to solve this question?

How we all solved it

Talking to class-mates after the test - turns out we all did the same thing to solve this question. We were allowed to use maple so we defined a cumulative distribution function:

$$cdf(n,p,t):=\sum_{i=0}^t \binom{n}{i}p^i(1-p)^{n-i}$$

And simply guessed the number:

$$cdf(50,0.07,6)=0.0583136357$$ $$cdf(50,0.07,7)=0.0220099488$$

So the answer became "It would take 7 toilets"

This is just an unsatisfying way to solve the problem, and dosent look that great either.

Additional attempts

When I got home, I tried to use maples "solve()" function to do something like:

$$solve(cdf(50,0.07,t)=0.05)$$

But maple could not find an answer there, so then I got desperate and tried things like:

$$solve(min(cdf(50,0.07,t)<0.05))$$

Which clearly was not going anywhere either, and now im out of ides.

So my question: Would you solve this question in a different manner? - if so how?

1

There are 1 best solutions below

0
On BEST ANSWER

We can make use of an extension of the factorial function for non-integer values. Ie, n! = Γ(n + 1)

https://en.wikipedia.org/wiki/Factorial#Factorial_of_non-integer_values

This allows us to obtain a continuous representation for which stock numeric rootfinding can be used. This allows for a short and simple approach using Maple.

Moreover, this approach removes the need to first discover an integer value of t for which the probability is less than 5%.

First I'll show it alongside some explanation, and then I'll show the short code the obtains the result.

NB. Your Question is tagged with Maple, and you show Maple code attempts to solve the problem, hence it very much appears that this is one kind of answer for which you are looking.

restart;
expr := binomial(n,i)*p^i*(1-p)^(n-i):

ext := convert(expr, GAMMA);

    GAMMA(1+n)/GAMMA(1+i)/GAMMA(n-i+1)*p^i*(1-p)^(n-i)

Here is sum(ext, i=0..t), simplified only for convenience.

new := simplify(subs(P=1-p,simplify(algsubs(1- 
                     p=P,expand(sum(ext, i=0..t))))),
                power)
          assuming t::posint, i::posint, i<=t,
                   n::posint, t<n, P>0, P<1;

     1-GAMMA(1+n)/GAMMA(2+t)/GAMMA(n-t)*p^(t+1)
       *(1-p)^(-1+n-t)*hypergeom([1,1-n+t,[2+t],p/(-1+p))

We can check agreement at some positive integer values of t.

1 - evalf(eval(eval(Sum(expr, i=0..t),[n=50,p=0.07]), t=6));

              0.0583136357

1 - evalf(eval(eval(new,[n=50,p=0.07]), t=6));

              0.0583136357

1 - evalf(eval(eval(Sum(expr, i=0..t),[n=50,p=0.07]), t=7));

              0.0220099488

1 - evalf(eval(eval(new,[n=50,p=0.07]), t=7));

              0.0220099488

We can superimpose plots involving the discrete function and this continuous extension.

plots:-display(
  plot([seq([t,1-eval(Sum(expr, i=0..t),[n=50,p=0.07])], t=5..10)],
       style=point, color=blue, symbol=solidcircle, symbolsize=15),
  plot(1-eval(new,[n=50,p=0.07]), t=5..10),
  plot(0.05, t=5..10, color=gray)
);

enter image description here

Using numeric root-finding it is now simple to find the value of t for which this attains a value of 0.05 .

Note that we do not have the burden of supplying a value of t for which the probability was less than 0.05 .

rt := fsolve(1-eval(new,[n=50,p=0.07])=0.05,
             t=1..infinity);

           rt := 6.167238357

The next integer higher than that root

ceil(rt);
                7

And, without all the exposition,

restart;
cdf:=sum(binomial(n,i)*p^i*(1-p)^(n-i),i=0..t): 
ceil(fsolve(1-eval(cdf,[n=50,p=0.07])=0.05,t=1..infinity));

                 7