Rolling Dice Data Analysis

Download Report

Transcript Rolling Dice Data Analysis

Rolling Dice Data Analysis
- Hidden Markov Model
Danielle Tan
Haolin Zhu
Observations-Histogram 1
Histogram of All Dice Rolls
2500
2000
1500
1000
500
0
1
2
3
4
5
6
Observations-Histogram 2
Histogram of Dice Rolls #1 to #1000
200
180
160
140
120
100
#1001-2000: loaded die 1?
80
60
Histogram of Dice Rolls #1001 to #2000
40
350
20
300
0
1
2
3
4
5
6
250
#1-1000: fair die?
200
150
100
Histogram of Dice Rolls #7001 to #8000
400
50
350
0
1
2
3
4
5
6
300
250
200
150
100
50
#7001-8000: loaded die 2?
0
1
2
3
4
5
6
Observations-Cumulative Sum
4
3.5
Cumulative Sum of Dice Roll Values
x 10
Actual Data
Fair Dice
3
2.5
2
1.5
1
0.5
0
0
1000
2000
15001980
3000
4000
5000
3690
379042504660
6000
5700
7000
6500
8000
7700
9000
Fair region’s slope = 3.5; Loaded regions have approx. same slope of 4.5
Observations- Histogram 3
250
200
150
3rd Loaded Region
100
Histogram of Dice Rolls #4250 to #4660
50
200
180
0
1
2
3
4
5
6
160
140
1st Loaded Region
120
100
80
60
40
Histogram of Dice Rolls #7000 to #7780
350
20
0
300
1
2
3
4
5
6
250
200
150
100
5th Loaded Region
50
0
1
2
3
4
5
6
Observations

2 dice: One is fair, one is loaded.

Loaded regions are:
#1500-1980; #3690-3790, #4250-4660, #57006500 & #7000-7700


Probability of 6 on the loaded dice is ½.
Once either of the dice is used, it will continue
being used for a while.
Hidden Markov Model

Known information:
A sequence of observations with integers between 1-6.

Questions of interest:




How was this data set generated?
What portion of the data was generated by the fair dice and
loaded dice respectively?
What are the probabilities of the transition between the dice?
What is the probability of generating 6 using the loaded
dice?
Hidden-Markov Model
Probabilities of the transition between the two
Define
states. two states:
0.05
Loaded
Fair
0.05
0.95
Transition Matrix:
 0.95 0.05 
A

 0.05 0.95 
0.95
A guess from
observation!
Hidden-Markov Model

In each state, there are 6 possible output:
1
Fair
Loaded
1/6
1/10
Emission Matrix:
 1/ 6 1/ 6 1/ 6 1/ 6 1/ 6 1/ 6 
1/6
1/10
b 3 

1/10 1/ 2 
4 1/10 1/101/61/10 1/10 1/10
2
1/6
1/10
5
1/6
1/10
6
Again
1/6 a guess!
1/2
Hidden-Markov Model
A set of observations:
y  ( y1 , y2 ,
yN )
The states are hidden:
s  (s1 , s2 ,
sN )
For example:
s=(FFFFFFFFLLLFFFLL…)
Given the output sequence y, we need to find the most likely set of
state transition and output probabilities. In other words, to derive
the maximum likelihood estimate of the parameters (transition
probabilities) of the HMM given a dataset of output sequences.
Forward-Backward algorithm
What is the probability that the actual state of the system is i at time t?
Pt (i)  P(st  i | y)

The probability of the observed data up to time t:
M
1 ( j )  b j ( y1 ); t 1 ( j)   bi ( y1 )Ai i bi ( y2 )...  t (i) Aij b j ( yt 1 )
1

12
2
The probability of the observed data after time t:
M
t 1 ( j )   Aij b j ( yt ) t ( j )
j 1

Then:
Pt (i ) 
 t (i ) t (i)
M
  (i) (i)
i 1
t
t
i 1
Baum-Welch re-estimation

Notice that we are using a guess of the transition
matrix and the emission matrix!

Re-estimation of A and b:
'
ij
A
 (i) A b ( y ) 


  (i) (i)
t
t
ij
t

j
t
t 1
t
t 1
( j)
 ( y , k ) (i)  (i)

b (k ) 
  (i) (i)
'
i
t
t
t
t
t
t
t
Then we are able to iterate until it converges—we
keep track of the probability of the whole data set
generated by the given parameters until it converges
to a maximum.
Results

Transition matrix:

Emission matrix:
 0.9982 0.0018 
A

 0.0036 0.9964 
 0.1696 0.1766 0.1583 0.1661 0.1649 0.1645 
b

 0.0985 0.0973 0.1019 0.0951 0.1051 0.5022 
Results

Time when the loaded dice was used:
Results

Histogram of the data generated by the HiddenMarkov model:
Results

Cumulative sum of the data generated by the Hidden
Markov model:
Results

Log of the likelihood