Reviewing Movies II

Roger reviews movies and uses a 3-star system. He gives each movie i i stars with probability p i p_i , where the probabilities are { p 1 , p 2 , p 3 } = { 17 % , 79 % , 4 % } \{p_1, p_2, p_3\} = \{ 17 \, \%, 79 \, \%, 4 \, \% \} . If his scoring starts with 3 , 3 , 1 , 2 , 2 , 2 , 1 , . . . 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 \mu_k be the expected length of run k k (i.e. k-th run from start).

You are given that μ 1 = 18631 4648 \mu_1 = \frac{18631}{4648} .

Find μ 1 + μ 2 + μ 3 + μ 4 + μ 5 \mu_1 + \mu_2 + \mu_3 + \mu_4 + \mu_5 in the form a b \frac ab , where a a and b b are coprime positive integers, and give your answer as a + b . a + b.

Consider using a computer and writing some code.


The answer is 33462799103059.

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.

3 solutions

Mark Hennings
Oct 29, 2017

If R R is any run, then the probability that that run has length at least n n , given that it is a run of k k stars, is P [ R n k stars ] = p k n 1 n 1 \mathbb{P}[R \ge n| k \; \text{stars}] \; = \; p_k^{n-1} \hspace{2cm} n \ge 1 and hence the expected length of a run, given that is a run of k k stars, is n 1 P [ R n k stars ] = 1 1 p k \sum_{n \ge 1} \mathbb{P}[R \ge n| k \; \text{stars}] \; = \; \frac{1}{1-p_k} 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 2 p 2 + p 3 p 3 p 2 + p 3 p 1 p 1 + p 3 0 p 3 p 1 + p 3 p 1 p 1 + p 2 p 2 p 1 + p 2 0 ) \left(\begin{array}{ccc} 0 & \frac{p_2}{p_2+p_3} & \frac{p_3}{p_2+p_3} \\ \frac{p_1}{p_1+p_3} & 0 & \frac{p_3}{p_1+p_3} \\ \frac{p_1}{p_1+p_2} & \frac{p_2}{p_1+p_2} & 0 \end{array}\right) and hence the expected length of the n n th run is μ n = ( p 1 p 2 p 3 ) T ( 0 p 2 p 2 + p 3 p 3 p 2 + p 3 p 1 p 1 + p 3 0 p 3 p 1 + p 3 p 1 p 1 + p 2 p 2 p 1 + p 2 0 ) n 1 ( 1 1 p 1 1 1 p 2 1 1 p 3 ) \mu_n \; = \; \left(\begin{array}{c} p_1 \\ p_2 \\ p_3\end{array}\right)^T \left(\begin{array}{ccc} 0 & \frac{p_2}{p_2+p_3} & \frac{p_3}{p_2+p_3} \\ \frac{p_1}{p_1+p_3} & 0 & \frac{p_3}{p_1+p_3} \\ \frac{p_1}{p_1+p_2} & \frac{p_2}{p_1+p_2} & 0 \end{array}\right)^{n-1} \left(\begin{array}{c} \tfrac{1}{1-p_1} \\ \tfrac{1}{1-p_2} \\ \tfrac{1}{1-p_3} \end{array}\right) With p 1 = 0.17 p_1 = 0.17 , p 2 = 0.79 p_2 = 0.79 , p 3 = 0.04 p_3 = 0.04 we obtain μ 1 = 18631 4648 μ 2 = 19573 10458 μ 3 = 374027959 97217568 μ 4 = 1757602213 874958112 μ 5 = 7565208908051 2033402652288 \mu_1 = \frac{18631}{4648} \hspace{1cm} \mu_2 = \frac{19573}{10458} \hspace{1cm} \mu_3 = \frac{374027959}{97217568} \hspace{1cm} \mu_4 = \frac{1757602213}{874958112} \hspace{1cm} \mu_5 = \frac{7565208908051}{2033402652288} so that j = 1 5 μ j = 31429396450771 2033402652288 \sum_{j=1}^5 \mu_j \; = \; \frac{31429396450771}{2033402652288} making the answer 33462799103059 \boxed{33462799103059} .

Ivo Zerkov
Oct 30, 2017

I find a recursive relation for μ n \mu_{n} and solve it with a Python3 program.

Let a , b , c a,b,c be p 1 , p 2 , p 3 p_{1},p_{2},p_{3} , in no particular order, and P ( x , n ) P(x,n) be the probability the n n -th run is a run of reviews which appear with probability x x . For example, P ( 0.79 , 4 ) P(0.79,4) is the probability the 4 4 -th run is one made of 2 2 -star reviews.

Then P ( a , n ) = a a + b P ( c , n 1 ) + a a + c P ( b , n 1 ) P(a,n)=\frac{a}{a+b}P(c,n-1)+\frac{a}{a+c}P(b,n-1) , since for a run to be made of, say, 1 1 -star reviews, the previous run must be one of 2 2 -star or 3 3 -star reviews, and, of course, the first review must be a 1 1 star.

Finally, the expected length of a run made of reviews which appear with probability x x is 1 1 x \frac{1}{1-x} .

We're then looking to find P ( p 1 , 5 ) 1 p 1 + P ( p 2 , 5 ) 1 p 2 + P ( p 3 , 5 ) 1 p 3 \frac{P(p_{1},5)}{1-p_1}+\frac{P(p_{2},5)}{1-p_2}+\frac{P(p_{3},5)}{1-p_3} , given that P ( p k , 1 ) = p k P(p_{k},1)=p_{k} for k = 1 , 2 , 3 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
from fractions import *

memory={}
probs=[17,79,4]

#Set up base cases:
for i in range(0,3):
  memory[(probs[i],1)]=Fraction(probs[i],100)

def P(a,n):
  if (a,n) in memory:
    return memory[(a,n)]

  #Get b and c values:
  b=0
  c=0
  for i in range(0,3):
    if probs[i]!=a and b==0:
      b=probs[i]
    elif probs[i]!=a:
      c=probs[i]

  #Our recursive relation:
  ans=Fraction(a,a+b)*P(c,n-1)+Fraction(a,a+c)*P(b,n-1)

  #Add to memory:
  memory[(a,n)]=ans

  return ans

s=0
for i in range(1,6):  

  #Expected length of i-th run:
  expected=0
  for j in range(0,3):
    expected+=P(probs[j],i)/(1-Fraction(probs[j],100))

  s+=expected
print(s)

Output is 31429396450771 / 2033402652288 31429396450771/2033402652288 , making the answer 33462799103059 33462799103059

Borut Levart
Oct 29, 2017

First run starts with an i i -star review with probability p i p_i and ends after 1 / q i 1/q_i movies reviewed on average, with q i = 1 p i q_i = 1 - p_i , since that is the expected number of Bernoulli trials until a non- i 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 p_2/q_1 and p 3 / q 1 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 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 n -star reviewing. Let's write down one term for μ 3 \mu_3 which represents the "1-run, 2-run, 1-run" possibility.

p 1 p 2 q 1 p 1 q 2 1 q 1 = p 1 q 1 p 2 q 2 p 1 q 1 p_1 \, \frac{p_2}{q_1} \, \frac{p_1}{q_2} \, \frac{1}{q_1} = \frac{p_1}{q_1} \, \frac{p_2}{q_2} \, \frac{p_1}{q_1}

Such terms should be summed over all possible root-to-leaf paths, which turns out to be tuples of elements { 1 , 2 , 3 } \{1, 2, 3\} with distinct successive elements. There are 12 such tuples for n = 3 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.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...