Roger reviews movies and uses a 3-star system. He gives each movie i stars with probability p i , where the probabilities are { p 1 , p 2 , p 3 } = { 1 7 % , 7 9 % , 4 % } . If his scoring starts with 3 , 3 , 1 , 2 , 2 , 2 , 1 , . . . , there is a run of three stars of length two at the beginning, followed by a run of one star of length one, a run of two stars of length three, etc. Let μ k be the expected length of run k (i.e. k-th run from start).
You are given that μ 1 = 4 6 4 8 1 8 6 3 1 .
Find μ 1 + μ 2 + μ 3 + μ 4 + μ 5 in the form b a , where a and b are coprime positive integers, and give your answer as a + b .
Consider using a computer and writing some code.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
I find a recursive relation for μ n and solve it with a Python3 program.
Let a , b , c be p 1 , p 2 , p 3 , in no particular order, and P ( x , n ) be the probability the n -th run is a run of reviews which appear with probability x . For example, P ( 0 . 7 9 , 4 ) is the probability the 4 -th run is one made of 2 -star reviews.
Then P ( a , n ) = a + b a P ( c , n − 1 ) + a + c a P ( b , n − 1 ) , since for a run to be made of, say, 1 -star reviews, the previous run must be one of 2 -star or 3 -star reviews, and, of course, the first review must be a 1 star.
Finally, the expected length of a run made of reviews which appear with probability x is 1 − x 1 .
We're then looking to find 1 − p 1 P ( p 1 , 5 ) + 1 − p 2 P ( p 2 , 5 ) + 1 − p 3 P ( p 3 , 5 ) , given that P ( p k , 1 ) = p k for k = 1 , 2 , 3 .
So here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
Output is 3 1 4 2 9 3 9 6 4 5 0 7 7 1 / 2 0 3 3 4 0 2 6 5 2 2 8 8 , making the answer 3 3 4 6 2 7 9 9 1 0 3 0 5 9
First run starts with an i -star review with probability p i and ends after 1 / q i movies reviewed on average, with q i = 1 − p i , since that is the expected number of Bernoulli trials until a non- i outcome. If the first run starts with one star, it ends with either a two-star or a three-star review, with respective probabilities p 2 / q 1 and p 3 / q 1 . Mind that the conditional probabilities of a 2- and 3-star review are normalized to the given that a 1-star run cannot be ended with a 1-star review. If the initial 1-star run is ended with a 2-star review, the second run is then a 2-star run and ends after 1 / q 2 movies reviewed on average, etc.
The processes is governed by a two-way probability branching save for the initial three-way branching. The same logic applies to general n -star reviewing. Let's write down one term for μ 3 which represents the "1-run, 2-run, 1-run" possibility.
p 1 q 1 p 2 q 2 p 1 q 1 1 = q 1 p 1 q 2 p 2 q 1 p 1
Such terms should be summed over all possible root-to-leaf paths, which turns out to be tuples of elements { 1 , 2 , 3 } with distinct successive elements. There are 12 such tuples for n = 3 . This readily suggests two programming approaches one can try. Both my solutions are written in Mathematica, or the Wolfram Language as it's called now. First I did a sum over tuples.
Second approach is more traditional perhaps, traversing the probability tree.
Problem Loading...
Note Loading...
Set Loading...
If R is any run, then the probability that that run has length at least n , given that it is a run of k stars, is P [ R ≥ n ∣ k stars ] = p k n − 1 n ≥ 1 and hence the expected length of a run, given that is a run of k stars, is n ≥ 1 ∑ P [ R ≥ n ∣ k stars ] = 1 − p k 1 Thus we need to consider the Markov chain whose states are the number of stars that are being counted in successive runs. This Markov chain has transition matrix ⎝ ⎛ 0 p 1 + p 3 p 1 p 1 + p 2 p 1 p 2 + p 3 p 2 0 p 1 + p 2 p 2 p 2 + p 3 p 3 p 1 + p 3 p 3 0 ⎠ ⎞ and hence the expected length of the n th run is μ n = ⎝ ⎛ p 1 p 2 p 3 ⎠ ⎞ T ⎝ ⎛ 0 p 1 + p 3 p 1 p 1 + p 2 p 1 p 2 + p 3 p 2 0 p 1 + p 2 p 2 p 2 + p 3 p 3 p 1 + p 3 p 3 0 ⎠ ⎞ n − 1 ⎝ ⎛ 1 − p 1 1 1 − p 2 1 1 − p 3 1 ⎠ ⎞ With p 1 = 0 . 1 7 , p 2 = 0 . 7 9 , p 3 = 0 . 0 4 we obtain μ 1 = 4 6 4 8 1 8 6 3 1 μ 2 = 1 0 4 5 8 1 9 5 7 3 μ 3 = 9 7 2 1 7 5 6 8 3 7 4 0 2 7 9 5 9 μ 4 = 8 7 4 9 5 8 1 1 2 1 7 5 7 6 0 2 2 1 3 μ 5 = 2 0 3 3 4 0 2 6 5 2 2 8 8 7 5 6 5 2 0 8 9 0 8 0 5 1 so that j = 1 ∑ 5 μ j = 2 0 3 3 4 0 2 6 5 2 2 8 8 3 1 4 2 9 3 9 6 4 5 0 7 7 1 making the answer 3 3 4 6 2 7 9 9 1 0 3 0 5 9 .