Debian Codegraph @

examples/ai/hmm/hmm-train.ck

raw
1 //------------------------------------------------------------------------------
2 // name: hmm-train.ck
3 // desc: basic hidden markov model (HMM) usage example (using train)
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 // train
19 [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2] @=> int observations[];
20 hmm.train( 2, 3, observations );
21
22 // generate
23 int results[30];
24 hmm.generate( 30, results );
25
26 // output
27 for ( 0 => int i; i < results.size(); i++ )
28 {
29 chout <= results[i] <= " ";
30 }
31 chout <= IO.newline();