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

📄 hmm.h

📁 matlab 例程
💻 H
字号:
//文件:hmm.h
//功能:提供HMM的数据结构和定义

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define MAX(x,y)  ((x)>(y)?(x):(y))
#define MIN(x,y)  ((x)<(y)?(x):(y))

struct HMM{
	int N;  /*状态的个数;*/
    int M;  /*观察值的个数;*/
	double **A; /*状态转移概率A[1..N][1..N]*/
	double **B; /*B[1..N][1..M],b[j][k]是在状态j观察到观察值k的概率*/
	double *pi; /*pi[1..N]pi[i]是进入Markov链的状态分布*/
	double *u;
	double *sigma;
};

/*关于序列的存取,状态的计算等*/


//前向后向算法,BaumWelch算法
void Forward(struct HMM *phmm,int T,int **O,double **alpha,double *pprob,int k);
void ForwardWithScale(struct HMM *phmm,int T,int **O,double **alpha,double *scale,double *pprob,int k);
void Backward(struct HMM *phmm,int T,int **O,double **beta,double *pprob,int k);
void BackwardWithScale(struct HMM *phmm,int T,int **O,double **beta,double *scale,double *pprob,int k);
void BaumWelch(struct HMM *phmm,int T,int **O,double **alpha,double **beta,
			   double **gamma,int *pniter,double *plogprobinit,double *plogprobfinal,int x,int y);
void BaumWelch0(struct HMM *phmm,int T,int **O,double **alpha,double **beta,
			   double **gamma,int *pniter,double *plogprobinit,double *plogprobfinal,int x,int y);
//Viterbi算法
double ***AllocXi(int T,int N);
void FreeXi(double ***xi,int T,int N);
void ComputeGamma(struct HMM *phmm,int T,double **alpha,double **beta,double **gamma);
void ComputeXi(struct HMM *phmm,int T,int **O,double **alpha,double **beta,
			   double ***xi,int k);
void Viterbi(struct HMM *phmm,int T,int **O,double **beta,int **psi,int *q,double *pprob,int k);
void ViterbiLog(struct HMM *phmm,int T,int **O,double **beta,int **psi,int **q,double *pprob,int k);

//随机相关函数
int hmmgetseed(void);
void hmmsetseed(int seed);
double hmmgetrand(void);







⌨️ 快捷键说明

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