#
-*- coding: cp936 -*-
from
MyViterbi
import
forward_viterbi
states
=
(
'
Rainy
'
,
'
Sunny
'
)
#
元组
observations
=
(
'
walk
'
,
'
shop
'
,
'
clean
'
)
#
元组
start_probability
=
{
'
Rainy
'
:
0.6
,
'
Sunny
'
:
0.4
}
transition_probility
=
{
'
Rainy
'
:{
'
Rainy
'
:
0.7
,
'
Sunny
'
:
0.3
},
'
Sunny
'
:{
'
Rainy
'
:
0.4
,
'
Sunny
'
:
0.6
}
}
emission_probability
=
{
'
Rainy
'
:{
'
walk
'
:
0.1
,
'
shop
'
:
0.4
,
'
clean
'
:
0.5
},
'
Sunny
'
:{
'
walk
'
:
0.6
,
'
shop
'
:
0.3
,
'
clean
'
:
0.1
}
}
observation
=
(
'
walk
'
,
'
clean
'
,
'
walk
'
)
c
=
forward_viterbi(observation,states,start_probability,transition_probility,emission_probability)
print
c