An archive the questions from Mark's Fall 2018 Stat 225.

Ranking your random conference

Mark

(15 pts)

Let us suppose that four teams (OSU, UM, NU, and MSU) play each other five times each. Here’s a webpage that generates some possible results for such a scenario and presents them as a directed graph. Referring to that page,

  1. Use the provided graphviz code to share your results with us.
  2. Translate your directed graph to an adjacency matrix typeset with AsciiMath.
  3. Type out the equations that you would need to solve in order to find the Maximum Likelihood ranking of the teams.
  4. Solve the equations using the Python code presented in our outline.
  5. Type out the ranking with respective strengths.
  6. Find the probability that OSU beats NU.
audrey

That sounds fun!!!

Here’s my random graph:

vizgraph-20181130-433-ea1ie4.png

Ordering the teams alphabetically (MSU, NU, OSU, UM), my matrix is:

((0,3,2,1), (2, 0, 1, 2), (3,4,0,3), (4,3,2,0))

This leads to the following equations:

6/r_0 - (5/(r_0 + r_1) + 5/(r_0 + r_2) + 5/(r_0+r_3)) = 0
5/r_1 - (5/(r_1 + r_0) + 5/(r_1 + r_2) + 5/(r_1+r_3)) = 0
10/r_2 - (5/(r_2 + r_0) + 5/(r_2 + r_1) + 5/(r_1+r_3)) = 0
9/r_3 - (5/(r_3 + r_0) + 5/(r_3 + r_1) + 5/(r_3+r_2)) = 0

dennis

My Graph (Hah! First…)

vizgraph-20181130-433-p9xuzn.png

My Matrix:

MSU = 1
NU  = 2
OSU = 3
UM  = 4

((0,4,4,3), (1,0,4,2), (1,1,0,1), (2,3,4,0))

Using the above matrix, with the following formula:

image

11/r_0 - (5/(r_0+r_1) + 5/(r_0+r_2) + 5/(r_0+r_3))=0
7/r_1 - (5/(r_1+r_0) + 5/(r_1+r_2) + 5/(r_1+r_3))=0
3/r_2 - (5/(r_2+r_0) + 5/(r_2+r_1) + 5/(r_2+r_3))=0
9/r_0 - (5/(r_3+r_0) + 5/(r_3+r_1) + 5/(r_3+r_2))=0

My Code:

from scipy.optimize import root
def g(r):
    r0=r[0]
    r1=r[1]
    r2=r[2]
    r3=r[3]
    return [
        11/r0 - 0/(r0+r0) - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3),
        7/r1 - 5/(r1+r0) - 0/(r1+r1) - 5/(r1+r2) - 5/(r1+r3),
        3/r2 - 5/(r2+r0) - 5/(r2+r1) - 0/(r2+r2) - 5/(r2+r3),
        9/r3 - 5/(r3+r0) - 5/(r3+r1) - 5/(r3+r2) - 0/(r3+r3),
    ]
solution = root(g, [1/3,1/3,1/3,1/3])
if solution.success:
    r = solution.x/sum(solution.x)
    print(r)
else:
    print('uh-oh!')

(I left the 0/(r_i+r_j) to make it easier for me to visualize)

Output:
[ 0.46021753 0.1833029 0.06935212 0.28712744]

Relative Strengths:

M = 0.46
N =0.18
O =0.069
U =0.28

P O beats U:

0.06935212/(0.06935212+0.1833029)

=0.274493338782661

= 27.4 %

goodmorning
vizgraph-20181130-433-1x24vze.png

My matrix is
MSU NU OSU UM
((0,1,4,4),(4,0,1,3),(1,4,0,2),(1,2,3,0))

The Equations are
11/(r0) - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3)=0
7/(r1) - 5/(r0+r1) - 5/(r1+r2) - 5/(r1+r3)=0
3/(r2) - 5/(r0+r2) - 5/(r1+r2) - 5/(r3+r2)=0
9/(r3) - 5/(r0+r3) - 5/(r1+r3) - 5/(r2+r3)=0

then we use

from scipy.optimize import root
def g(r):
    r0=r[0]
    r1=r[1]
    r2=r[2] 
    r3=r[3]
    return [
        11/r0 - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3),
        7/r1 - 5/(r0+r1) - 5/(r1+r2) - 5/(r1+r3),
        3/r2 - 5/(r0+r2) - 5/(r1+r2) - 5/(r3+r2),
        9/r3 - 5/(r0+r3) - 5/(r1+r3) - 5/(r2+r3)
    ]
solution = root(g, [11,7,3,9])
if solution.success:
    r = solution.x/sum(solution.x)
    print(r)
else:
    print('uh-oh!')

the answers give us the following ranking
1 MSU=0.46021753
2 UM=0.28712744
3 NU=0.1833029
4 OSU=0.06935212

Chance of OSU beating NU
0.06935212/(0.06935212+0.1833029)=0.274493338782661
which gives me a 0.274493338782661 probability of OSU beating NU

Tripp
vizgraph-20181130-433-2naycy.png

My matrix corresponding to the graph:

MSU, NU, OSU, UM

((0,1,3,2),(4,0,2,2),(2,3,0,3),(3,3,2,0))

from scipy.optimize import root
import numpy as np
def g(r):
r0 = r[0]
r1 = r[1]
r2 = r[2]
r3 = r[3]
return [
    6/r0 - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3),
    8/r1 - 5/(r1+r0) - 5/(r1+r2) - 5/(r1+r3),
    8/r2 - 5/(r2+r0) - 5/(r2+r1) - 5/(r2+r3),
    8/r3 - 5/(r3+r0) - 5/(r3+r1) - 5/(r3+r2)
]
solution = root(g, np.ones(4))
solution.x/sum(solution.x)

Rankings ([ 0.18181818, 0.27272727, 0.27272727, 0.27272727])

(0.27272727)/(0.27272727+0.27272727)

50% chance Ohio State beats Northwestern

joshua

For my random graph I got…

vizgraph-20181203-433-my9h77.png

My Matrix is (MSU=0, NU=1, OSU=2, UM=3)

M=((0,1,3,2),(4,0,1,3),(2,4,0,2),(3,2,3,0))

The four equations that I would need are…

6/r_0(5/(r_0+r_1)+5/(r_0+r_2)+5/(r_0+r_3))=0
8/r_1(5/(r_1+r_0)+5/(r_1+r_2)+5/(r_1+r_3))=0
8/r_2(5/(r_2+r_0)+5/(r_2+r_1)+5/(r_2+r_3))=0
8/r_3(5/(r_3+r_0)+5/(r_3+r_1)+5/(r_3+r_2))=0

Then I use…

from scipy.optimize import root
def g(r):
r0=r[0]
r1=r[1]
r2=r[2]
r3=r[3]
return [
6/r0 - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3),
8/r1 - 5/(r1+r0) - 5/(r1+r2) - 5/(r1+r3),
8/r2 - 5/(r2+r0) - 5/(r2+r1) - 5/(r2+r3),
8/r3 - 5/(r3+r0) - 5/(r3+r1) - 5/(r3+r2)
]
solution = root(g, [1/4,1/4,1/4,1/4])
if solution.success:
r = solution.x/sum(solution.x)
print(r)
else:
print('uh-oh!')

OUTPUT: [ 0.18181818  0.27272727  0.27272727  0.27272727]

The ranking is NU=OSU=UM=0.27272727>MSU=0.18181818

The probability that OSU beats NU is…
r_1/(r_2+r_1)=0.27272727/(0.27272727+0.27272727)=0.50 =50%

Garrett
vizgraph-20181130-433-f1ywry.png
  1. My matrix is:

((0,3,2,1), (2,0,2,1), (3,3,0,2), (4,4,3,0) )

The rows in the matrix correspond to MSU, NU, OSU, UM, respectively

My system of equations:

6/r_0 - 5/(r_0+r_1) - 5/(r_0+r_2) - 5/(r_0+r_3)=0

5/r_1 - 5/(r_1+r_0) - 5/(r_1+r_2) - 5/(r_1+r_3)=0

8/r_2 - 5/(r_2+r_0) - 5/(r_2+r_1) - 5/(r_2+r_3)=0

11/r_3 - 5/(r_3+r_0) - 5/(r_3+r_1) - 5/(r_3+r_2)=0

  1. Enter my equations into Python:

    from scipy.optimize import root
    import numpy as np
    def g(r):
    r0 = r[0]
    r1 = r[1]
    r2 = r[2]
    r3 = r[3]
    return [
     6/r0 - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3),
     5/r1 - 5/(r1+r0) - 5/(r1+r2) - 5/(r1+r3),
     8/r2 - 5/(r2+r0) - 5/(r2+r1) - 5/(r2+r3),
     11/r3 - 5/(r3+r0) - 5/(r3+r1) - 5/(r3+r2)
    ]
     solution = root(g, [1/4,1/4,1/4, 1/4])
    if solution.success:
    r = solution.x/sum(solution.x)
    print(r)
    else:
    print('uh-oh!')
    
  2. My output r is:

    [ 0.15797135  0.12673478  0.24210126  0.47319261]
    
  3. The probablilty is that OSU beats NU:

    r_2/(r_2+r_1)=.45

vscala
vizgraph-20181130-433-1umpu2l.png

(OSU, UM, NU, and MSU)

((0,4,2,2),(1,0,2,2),(3,3,0,4),(3,3,1,0))

8/r_0 - 5/(r_0+r_1) - 5/(r_0+r_2) - 5/(r_0+r_3) = 0
5/r_1 - 5/(r_1+r_0) - 5/(r_1+r_2) - 5/(r_1+r_3) = 0
10/r_2 - 5/(r_2+r_0) - 5/(r_2+r_1) - 5/(r_2+r_3) = 0
7/r_3 - 5/(r_3+r_0) - 5/(r3+r_1) - 5/(r_3+r_2) = 0

from scipy.optimize import root
import numpy as np
def g(r):
    r0 = r[0]
    r1 = r[1]
    r2 = r[2]
    r3 = r[3]
    return [
        8/r0 - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3),
        5/r1 - 5/(r1+r0) - 5/(r1+r2) - 5/(r1+r3),
        10/r2 - 5/(r2+r0) - 5/(r2+r1) - 5/(r2+r3),
        7/r3 - 5/(r3+r0) - 5/(r3+r1) - 5/(r3+r2)
    ]
solution = root(g, np.ones(4))
solution.x/sum(solution.x)

Strengths:
[0.25814583, 0.13714417, 0.39490846, 0.20980154]

OSU beats NU: (.25814583)/(.25814583+.39490846)
39.52%

john

Here’s my random graph:

vizgraph-20181130-433-18qcg1x.png

MSU = 0,
NU = 1,
OSU = 2,
UM = 3

My matrix is
M =((0,2,1,3),(3,0,1,4),(4,4,0,1),(2,1,4,0))

My system of equations:
6/r_0 - (5/(r_0+r_1)+5/(r_0+r_2)+5/(r_0+r_3))=0
8/r_1 - (5/(r_1+r_0)+5/(r_1+r_2)+5/(r_1+r_3))=0
9/r_2 - (5/(r_2+r_0)+5/(r_2+r_1)+5/(r_2+r_3))=0
7/r_3 - (5/(r_3+r_0)+5/(r_3+r_1)+5/(r_3+r_2))=0

Then I calculated my strengths with this code:

from scipy.optimize import root
def g(r):
    r_0=r[0]
    r_1=r[1]
    r_2=r[2]
    r_3=r[3]
    return [
        6/r_0 - (5/(r_0+r_1)+5/(r_0+r_2)+5/(r_0+r_3)),
        8/r_1 - (5/(r_1+r_0)+5/(r_1+r_2)+5/(r_1+r_3)),
        9/r_2 - (5/(r_2+r_0)+5/(r_2+r_1)+5/(r_2+r_3)),
        7/r_3 - (5/(r_3+r_0)+5/(r_3+r_1)+5/(r_3+r_2))
    ]
solution = root(g, [1/4,1/4,1/4,1/4])
if solution.success:
    r = solution.x/sum(solution.x)
    print(r)
else:
    print('uh-oh!')

Strengths:
[ 0.17936632 0.26961329 0.33088901 0.22013137]

The probability that OSU beats NU is:

(.33088901)/(.33088901+0.26961329)=0.5510203874323212

There is a 55.1% chance OSU beats NU.

megan

Here’s my random graph

vizgraph-20181130-433-uy30d9.png

My matrix is

((0,3,1,1),(2,0,2,3),(4,3,0,1),(4,2,4,0))

This leads to the following equations

5/r_0-(5/(r_0+r_1)+5/(r_0+r_2)+5/(r_0+r_3))=0
7/r_1-(5/(r_0+r_1)+5/(r_1+r_2)+5/(r_1+r_3))=0
8/r_2-(5/(r_0+r_2)+5/(r_1+r_2)+5/(r_2+r_3))=0
10/r_3-(5/(r_0+r_3)+5/(r_1+r_3)+5/(r_2+r_3))=0

I solved the equations using the following Python code

from scipy.optimize import root
def g(r):
    r_0=r[0]
    r_1=r[1]
    r_2=r[2]
    r_3=r[3]
    return [
        5/r_0-(5/(r_0+r_1)+5/(r_0+r_2)+5/(r_0+r_3)),
        7/r_1-(5/(r_0+r_1)+5/(r_1+r_2)+5/(r_1+r_3)),
        8/r_2-(5/(r_0+r_2)+5/(r_1+r_2)+5/(r_2+r_3)),
        10/r_3-(5/(r_0+r_3)+5/(r_1+r_3)+5/(r_2+r_3))
    ]
solution = root(g, [1/4,1/4,1/4,1/4])
if solution.success:
    r = solution.x/sum(solution.x)
    print(r)
else:
    print('uh-oh!')

Output:

[ 0.13714417  0.20980154  0.25814583  0.39490846]

Strengths:

MSU = 0.13714417
NU = 0.20980154
OSU = 0.25814583
UM = 0.39490846

OSU beats NU:

0.25814583/(0.20980154+0.25814583)=0.5516556915364221

55.17%

btucker

Here’s my random graph

vizgraph-20181130-433-135xh0v.png

My matrix is
(MSU,NU,OSU,UM)

((0,4,3,1),(1,0,1,4),(2,4,0,2),(4,1,3,0))

My equations:

8/r_0-(5/(r_0+r_1)+5/(r_0+r_2)+5/(r_0+r_3))=0
6/r_1-(5/(r_0+r_1)+5/(r_1+r_2)+5/(r_1+r_3))=0
8/r_2-(5/(r_0+r_2)+5/(r_1+r_2)+5/(r_2+r_3))=0
8/r_3-(5/(r_0+r_3)+5/(r_1+r_3)+5/(r_2+r_3))=0

from scipy.optimize import root
def g(r)
r0=r[0]
r1=r[1]
r2=r[2]
r3=r[3]
return [
    8/r0 - 5/(r0+r1) - 5/(r0+r2)-5/(r0+r3),
    6/r1 - 5/(r0+r1) - 5/(r1+r2)-5/(r1+r3),
    8/r2 - 5/(r0+r2) - 5/(r1+r2)-5/(r2+r3),
    8/r3 - 5/(r0+r3) - 5/(r1+r3)-5/(r2+r3),
]


solution = root(g, [1/4,1/4,1/4,1/4])
if solution.success:
r = solution.x/sum(solution.x)
print(r)
else:
print('uh-oh!')

Out:

[ 0.27272727,  0.18181818,  0.27272727,  0.27272727]

Probability OSU beats NU:

0.27272727/( 0.18181818+0.27272727)

Out:

0.6
Rebecca
vizgraph-20181130-433-3hxsmx.png

I suppose the order of the teams matter when it comes to writing the matrix. The columns correspond to NU, OSU, MSU, and UM. (It was clockwise around the kind of confusing circular graph.) If I do that, my matrix must be:

((0,1,1,4),(4,0,2,3),(4,3,0,2),(1,2,3,0))

And my equations – if I understand this correctly, and I’m really not sure that I do – must be:

\frac{6}{r_{NU}}-(\frac{5}{r_{NU}+r_{OSU}}+\frac{5}{r_{NU}+r_{MSU}}+\frac{5}{r_{NU}+r_{UM}})=0
\frac{9}{r_{OSU}}-(\frac{5}{r_{OSU}+r_{NU}}+\frac{5}{r_{OSU}+r_{MSU}}+\frac{5}{r_{OSU}+r_{UM}})=0
\frac{9}{r_{MSU}}-(\frac{5}{r_{MSU}+r_{NU}}+\frac{5}{r_{MSU}+r_{OSU}}+\frac{5}{r_{MSU}+r_{UM}})=0
\frac{6}{r_{UM}}-(\frac{5}{r_{UM}+r_{NU}}+\frac{5}{r_{UM}+r_{OSU}}+\frac{5}{r_{UM}+r_{MSU}})=0

And, yeah, I know I’ve just made more work for myself. I’ll have to re-type the lot in Python, but since I was going to have to switch computers just to use Python anyway… in for a penny, in for a pound?

Anyway, my code was

from scipy.optimize import root
def g(r):
    rn=r[0]
    ro=r[1]
    rm=r[2]
   ru=r[3]
    return[
    6/rn - 5/(rn+ro)-5/(rn+rm)-5/(rn+ru),
        9/ro - 5/(ro+rn)-5/(ro+rm)-5/(ro+ru),
    9/rm - 5/(rm+rn)-5/(rm+ro)-5/(rm+ru),
    6/ru - 5/(ru+rn)-5/(ru+ro)-5/(ru+rm),
]
solution = root(g, [1/4, 1/4, 1/4, 1/4])
if solution.success:
r = solution.x/sum(solution.x)
print(r)
else:
    print ('uh-oh!')

and the output was [ 0.175 0.325 0.325 0.175].

mac

A Graph

vizgraph-20181130-433-1y2huae.png

A Matrix (alphabetical)

((0,4,1,3),(1,0,2,2),(4,3,0,3),(2,3,2,0))

Solve with the formula:

\frac{d}{dr_i}\log(f(\vec{r})) = \frac{1}{r_i}\sum_{j=0}^(n-1) m_{ij} - \sum_{j=0}^(n-1) \frac{m_{ij}+m_{ji}}{r_i+r_j}.

Solution:

8/r_0-(5/(r_0+r_1)+5/(r_0+r_2)+5/(r_0+r_3))=0
5/r_1-(5/(r_1+r_0)+5/(r_1+r_2)+5/(r_1+r_3))=0
10/r_2-(5/(r_2+r_0)+5/(r_2+r_1)+5/(r_2+r_3))=0
7/r_3-(5/(r_3+r_0)+5/(r_3+r_1)+5/(r_3+r_2))=0

Now in python:

from scipy.optimize import root
def g(r):
r0=r[0]
r1=r[1]
r2=r[2]
r3=r[3]
return [
8/r0 - 5/(r0+r1) - 5/(r0+r2) - 5/(r0+r3),
5/r1 - 5/(r1+r0) - 5/(r1+r2) - 5/(r1+r3),
10/r2 - 5/(r2+r0) - 5/(r2+r1) - 5/(r2+r3),
7/r3 - 5/(r3+r0) - 5/(r3+r1) - 5/(r3+r2),
]
solution = root(g, [8,5,10,7])
if solution.success:
r = solution.x/sum(solution.x)
print(r)
else:
print('uh-oh!')

And the result:

[ 0.25814583  0.13714417  0.39490846  0.20980154] 
OR
OSU>MSU>UM>NU

To predict whether or not OSU will beat NU:

r_2/(r_2+r_1) = 0.39490846/(0.39490846+0.20980154 = 0.65305429048 = 65.3%