-
Notifications
You must be signed in to change notification settings - Fork 0
/
hmm.js
86 lines (84 loc) · 1.43 KB
/
hmm.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var hmm = require( 'hmm' );
var aModel = new hmm(
[ 'b', 'i', 'a' ],
'a', [ 'w', 'm', 'g', 'm' ], {
'b': 0.375,
'i':0.5,
'a':0.125
}, {
'b': {
'b': 0.14,
'i': 0.57,
'a': 0.29
},
'i': {
'i': 0.54,
'a':0.46
},
'a': {
'b': 0.2,
'i': 0.3,
'a':0.5
}
}, {
'b': {
'w': 0.3,
'm': 0.5,
'g':0.1,
'm':0.1
},
'i': {
'w': 0.3,
'm': 0.3,
'g':0.2,
'm':0.2
},
'a': {
'w': 0.5,
'm': 0.5
}
}
);
/*
var aModel = new hmm(
[ 'beer', 'icecream', 'apple' ],
'apple', [ 'weather', 'mood', 'gender', 'married' ], {
'bear': 0.375,
'icecream':0.5,
'apple':0.125
}, {
'beer': {
'beer': 0.14,
'icecream': 0.57,
'apple': 0.29
},
'icecream': {
'icecream': 0.54,
'apple':0.46
},
'apple': {
'beer': 0.2,
'icecream': 0.3,
'apple':0.5
}
}, {
'beer': {
'weather': 0.3,
'mood': 0.5,
'gender':0.1,
'married':0.1
},
'icecream': {
'weather': 0.3,
'mood': 0.3,
'gender':0.2,
'married':0.2
},
'apple': {
'weather': 0.5,
'mood': 0.5
}
}
);
*/
//console.log( 'The probability that something white in a bottle is milk is ' + ( aModel.generationProbability( ['weather'] ) * 100 ) + '%.' );