Debian Codegraph @

examples/ai/hmm/hmm-load.ck

raw
1 //------------------------------------------------------------------------------
2 // name: hmm-load.ck
3 // desc: basic hidden markov model (HMM) usage example (using load)
4 //
5 // version: need chuck version 1.5.0.0 or higher
6 // sorting: part of ChAI (ChucK for AI)
7 //
8 // uncomment the next line to learn more about the KNN object:
9 // HMM.help();
10 //
11 // author: Yikai Li
12 // date: Spring 2023
13 //------------------------------------------------------------------------------
14
15 // init
16 HMM hmm;
17
18 // load
19 [0.6, 0.2, 0.2] @=> float initial[];
20 [[0.8, 0.1, 0.1],
21 [0.2, 0.7, 0.1],
22 [0.1, 0.3, 0.6]] @=> float transition[][];
23 [[0.7, 0.0, 0.3],
24 [0.1, 0.9, 0.0],
25 [0.0, 0.2, 0.8]] @=> float emission[][];
26 hmm.load( initial, transition, emission );
27
28 // generate
29 int observations[30];
30 hmm.generate( 30, observations );
31
32 // output
33 for ( 0 => int i; i < observations.size(); i++ )
34 {
35 chout <= observations[i] <= " ";
36 }
37 chout <= IO.newline();