⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myhmm.h

📁 一个马尔可夫模型的源码
💻 H
字号:
#ifndef DEMO
#define DEMO
#endif

#define HMM_FILE            "-hmm"
#define TRAINING_FILE       "-train"
#define TESTING_FILE        "-test"
#define TRAINED_HMM_FILE    "-trainedHmm"
#define TESTED_FILE         "-tested"
#define MODE				"-mode"

#define TRAINING 1
#define TESTING 2
#define TRAINING_TESTING 3

#define threshold 1e-100
#define threshold2 1e-10
#define threshold3 1e-10
#define noDefObservations -1


/* because two more states are included, two more observations are added */
#define extraObservations 2

/* N - number of possible states */
/* M - number of possible observation */
/* T - the length of the longest input sequence in the training file */
int N, M, T;
/* transition matrix - N x N */
double** transitions;
/* emission matrix - N x M */
double** emissions;
/* initial distribution - 1 x N*/
double* pi;
int iTrain; // the number of the training examples
int iTest;  // the number of the testing examples

char* observations; // char observations[ M ]; the array to store all the observations
int observationsDefined = FALSE;
char* defTrainedHmmFile = "default.trainedHmm";
char* defTestedFile = "default.testedFile";

double** alpha;//double alpha[ T ][ N ];
double** beta;//double beta[ T ][ N ];
char **trainData;
char **testData;

int body(int argc, char** argv);
void init();
void saveHmm(char *out);
void calTransitions();
void test(char* testedFile);
/* probability of the sequence given the HMM model */
double forward(char *line);
double backward(char *line);
void viterbi(char *line, char *buffer);
void baumWelch();
char getSymbol(int k);
int getObservation(char ch);
void readObservations(char** trainData);
void initTransitions();
void initEmissions();
void initPi();
void loadHMM(char* hmmFile);
void loadSeq(char***pSeq, char* seqFile);
int AllocateDataSpaceChar(char ***pData, int row, int col);
void post_processing();
void check_mode(int mode, char* trainFile, char* testFile);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -