|
||
Title: Expected number of days a box of tomatoes lasts Post by Aryabhatta on Apr 14th, 2010, 5:24pm I got this problem from a colleague at the company I work and this is what the email said: Code:
Edit: Changed tt to code for better readability. Also, I forgot to mention, I have only been able to show Limn->oo k/n <= 1-1/e. |
||
Title: Re: Expected number of days a box of tomatoes last Post by towr on Apr 15th, 2010, 5:51am It appears that k as function of n follows the recursion k(n) = [(2*n-1)*k(n-1) - (n-2)*k(n-2) - k(n-3)]/n (Which I got from simplifying: g(0) = 1 g(n) = n*g(n-1) + (-1)^n = (n-1) (g(n-1) + g(n-2)) f(0) = 0 f(n) = (n+1)*f(n-1) + g(n-1) where f(n) = n! k(n), which I've been examining based on the first dozen values. So I don't even have proof it actually, definitely, is the right formula. g(n) is the number of derangements for n elements.) k(n)/n does seem to go to 1-e-1, approaching it from above, but even that I can't manage to prove. ::) But perhaps that someone else can make something of it. |
||
Title: Re: Expected number of days a box of tomatoes last Post by towr on Apr 15th, 2010, 8:01am k(n) can also be written as k(n) = 2 k(n-1) - k(n-2) - (-1)n/n! k(n) = http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k (n-k)/(k+1)! k(n) = http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k (n+1)/(k+1)! - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k (k+1)/(k+1)! k(n) = (n+1) * http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k/(k+1)! - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k/k! k(n) = (n+1) * http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n - (-1)k+1/(k+1)! - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k/k! k(n) = (n+1) * http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=1..n+1 - (-1)k/k! - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k/k! k(n) = (n+1) * [1 - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n+1 (-1)k/k!] - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k/k! k(n) = n+1 - (n+1)*http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n+1 (-1)k/k! - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n (-1)k/k! k(n) = n+1 - (n+2)*http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=0..n+1 (-1)k/k! + (-1)n+1/(n+1)! So k(n) -> n+1 - (n+2)/e, and therefore k(n)/n -> 1 - 1/e Well, that's something at least. |
||
Title: Re: Expected number of days a box of tomatoes last Post by Aryabhatta on Apr 15th, 2010, 9:11am Interesting, towr. I was thinking along completely different lines! Here is the proof I had for the <= part. ------- Let the tomato which rots on day j be labeled j. So the rotting order is 1,2,3,…n. Now by symmetry, for n >= a >=j and n >= b >=j, probability that tomato a is eaten on day j = probability that tomato b is eaten on day j. Call this p_j. Let z_j be the probability that no tomato is eaten on day j. (z_j = 0 for j <= n/2) Thus we have that (n-j+1) * p_j + z_j = 1 This gives us the upper bound on p_j: p_j <= 1/(n-j+1) If e_i is the probability that tomato i is eaten, Then the expected number of days the basket lasts, k = e_1 + e_2 +… + e_n. Now e_i = p_1 + p_2 + … + p_i Thus e_i <= 1/n + 1/(n-1)+ … + 1/(n-i+1) = H_n – H_{n-i} Where H_n is the nth harmonic number: 1 + 1/2 + … + 1/n Choose r = integral part of n/e and break up e_1 + e_2 + .. + e_n as k = e_1 + e_2 + … + e_r + e_{r+1} + … + e_n <= e_1 + e_2 + … + e_r + 1 + 1 + … + 1 Using the fact that H_n – H_m = ln(n/m) + O(1/n^2) and Stirling’s approximation formula, ln(n!) = n*ln(n) – n + O(ln(n)) (ln(x) = natural logarithm of x) and doing some computations gives us the upper bound of 1-1/e |
||
Title: Re: Expected number of days a box of tomatoes last Post by towr on Apr 15th, 2010, 10:02am I'm not sure I understand correctly. We have k = http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifi=1..n e_i e_i = http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifj=1..i p_j p_j <= 1/(n-j+1) If we use the latter to determine the upper bound, I get k <= http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifi=1..n http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifj=1..i 1/(n-j+1) = n |
||
Title: Re: Expected number of days a box of tomatoes last Post by Aryabhatta on Apr 15th, 2010, 10:06am on 04/15/10 at 10:02:09, towr wrote:
We do this: k = e_1 + e_2 + … + e_r + e_{r+1} + … + e_n <= e_1 + e_2 + … + e_r + 1 + 1 + … + 1 Notice that we replaced e_{r+1} etc with 1, instead of Sum 1/(n+j-1) as those sums are more than 1. |
||
Title: Re: Expected number of days a box of tomatoes last Post by towr on Apr 15th, 2010, 10:14am Ah, of course. :-[ That explains things. The e_i obviously can't be more than 1, and those ones would. |
||
Powered by YaBB 1 Gold - SP 1.4! Forum software copyright © 2000-2004 Yet another Bulletin Board |