Repository navigation
Expand file tree
/
Copy pathgenSeq.cpp
More file actions
57 lines (48 loc) · 1.33 KB
/
Copy pathgenSeq.cpp
File metadata and controls
57 lines (48 loc) · 1.33 KB
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
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<vector<float> >trans(3, vector<float>(3,0.0)); //Transition matrix
vector<vector<float> >emat(2, vector<float>(2,0.0)); //Symbol emission probability matrix
vector<int>st;
vector<char>sy;
double n, m;(double) rand() / RAND_MAX;
int i = 20;
float val;
cout<<"Enter the transition matrix: ";
for(int i = 0; i <= 2; i++){
for(int j = 0; j <= 2; j++){
cin>>val;
trans[i][j] = val;
}
}
cout<<"Enter the symbol emission probabilities: ";
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
cin>>val;
emat[i][j] = val;
}
}
st.push_back(0);
while(i){
m = (double)rand()/RAND_MAX;
if(m < trans[st.back()][1])
st.push_back(1);
else
st.push_back(2);
n = (double)rand()/RAND_MAX;
if(n < emat[st.back()-1][0])
sy.push_back('H');
else
sy.push_back('T');
--i;
}
cout<<"State sequence generated: \n";
for(int i = 0; i < st.size(); i++){
cout<<st[i]<<" ";
}
cout<<"\nSymbol sequence generated: \n";
for(int i = 0; i < sy.size(); i++){
cout<<sy[i]<<" ";
}
cout<<"\n";
}