📄 model.h
字号:
Produces simple left-right models given sequences. The function "model_generate_from_sequence" is called for each model that should be made. The sequences are read in from the ASCII file and thrown away again when leaving the function. @return vector of models @param s: scanner @param new_models: number of models to produce */model **model_from_sequence_ascii(scanner_t *s, long *mo_number);/** Produces simple left-right models given sequences. The sequences are not read in from file, but exists already as a structur. @return vector of models @param s: scanner @param new_models: number of models to produce */model **model_from_sequence(sequence_t *sq, long *mo_number);/** Copies a given model. Allocates the necessary memory. @return copy of the model @param mo: model to copy */model* model_copy(const model *mo);/** Tests if all standardization requirements of model are fulfilled. (That is, if the sum of the probabilities is 1). @return 0 for succes; -1 for error @param mo: model to test */int model_check(const model* mo);/** Tests if number of states and number of outputs in the models match. @return 0 for succes; -1 for error @param mo: vector of models @param model_number: numbr of models */int model_check_compatibility(model **mo, int model_number);/** Produces a model, which generates the given sequence with probability 1. The model is a strict left-right model with one state for each element in the sequence and the output in state i is the i-th value in the sequence with probability 1. The model also has a final state, a state with no output. @return pointer to the produced model @param seq: sequence @param seq_len: length of the sequence @param anz_symb: number of symbols in the sequence*/model* model_generate_from_sequence(const int *seq, int seq_len, int anz_symb);/** Produces sequences to a given model. All memory that is needed for the sequences is allocated inside the function. It is possible to define the length of the sequences global (global_len > 0) or it can be set inside the function, when a final state in the model is reach (a state with no output). If the model has no final state, the sequences will have length MAX_SEQ_LEN. @return pointer to an array of sequences @param mo: model @param seed: initial parameter for the random value generator (an integer). If seed == 0, then the random value generator is not initialized. @param global_len: length of sequences (=0: automatically via final states) @param seq_number: number of sequences*/sequence_t *model_generate_sequences(model* mo, int seed, int global_len, long seq_number,int Tmax);/** Calculates the sum log( P( O | lambda ) ). Sequences, that can not be generated from the given model, are neglected. @return log(P) @param mo model @param sq sequences */double model_likelihood(model *mo, sequence_t *sq);/** Set transition from state 'i' to state 'j' to value 'prob'. NOTE: No internal checks - model might get broken if used carelessly. @param mo model @param i state index @param j state index @param prob probabilitys */void model_set_transition(model *mo, int i, int j, double prob);/** Writes a model in matrix format. @param file: output file @param mo: model*/void model_print(FILE *file, model *mo); /** Writes transition matrix of a model. @param file: output file @param mo: model @param tab: format: leading tabs @param separator: format: seperator for columns @param ending: format: end of a row */void model_A_print(FILE *file, model *mo, char *tab, char *separator, char *ending);/** Writes output matrix of a model. @param file: output file @param mo: model @param tab: format: leading tabs @param separator: format: seperator for columns @param ending: format: end of a row */void model_B_print(FILE *file, model *mo, char *tab, char *separator, char *ending);/** Writes initial allocation vector of a matrix. @param file: output file @param mo: model @param tab: format: leading Tabs @param separator: format: seperator for columns @param ending: format: end of a row */void model_Pi_print(FILE *file, model *mo, char *tab, char *separator, char *ending);/** Writes fix vector of a matrix. @param file: output file @param mo: model @param tab: format: leading Tabs @param separator: format: seperator for columns @param ending: format: end of a row */void model_fix_print(FILE *file, model *mo, char *tab, char *separator, char *ending);/** Writes transposed transition matrix of a model. @param file: output file @param mo: model @param tab: format: leading Tabs @param separator: format: seperator for columns @param ending: format: end of a row */void model_A_print_transp(FILE *file, model *mo, char *tab, char *separator, char *ending);/** Writes transposed output matrix of a model. @param file: output file @param mo: model @param tab: format: leading Tabs @param separator: format: seperator for columns @param ending: format: end of a row */ void model_B_print_transp(FILE *file, model *mo, char *tab, char *separator, char *ending);/** Writes transposed initial allocation vector of a matrix. @param file: output file @param mo: model @param tab: format: leading Tabs @param separator: format: seperator for columns @param ending: format: end of a row */void model_Pi_print_transp(FILE *file, model *mo, char *tab, char *ending);/** Writes a HMM in matrix format. The input model must be of type model_direct, that is, have the parameters saved as matrices. @param file: output file @param mo_d: model of type model_direct @param multip: number of copies to write*/void model_direct_print(FILE *file, model_direct *mo_d, int multip);/** Writes the parameters of a model sorted by states. Is not very concise. @param file: output file @param mo: model*/void model_states_print(FILE *file, model *mo); /** Frees all memory from a model, sets the pointers to NULL and variables to zero. @param mo_d HMM structure (\Ref{struct model_direct}) @param check Check structure (\Ref{struct hmm_check_t})*/void model_direct_clean(model_direct *mo_d, hmm_check_t *check); /** Tests compatibility of the model components. @return 0 for success; -1 for failure @param mo_d HMM structure (\Ref{struct model_direct}) @param check Check structure (\Ref{struct hmm_check_t})*/int model_direct_check_data(model_direct *mo_d, hmm_check_t *check); /** Computes probabilistic distance of two models @return the distance @param m0 model used for generating random output @param m model to compare with @param maxT maximum output length (for HMMs with absorbing states multiple sequences with a toal langth of at least maxT will be generated) @param symmetric flag, whether to symmetrize distance (not implemented yet) @param verbose flag, whether to monitor distance in 40 steps. Prints to stdout (yuk!)*/double model_prob_distance(model *m0, model *m, int maxT, int symmetric, int verbose);/** Frees all memory from a state, sets the pointers to NULL and variables to zero. @author Peter Pipenbacher @param my_state state to clean (\Ref{struct state})*/void state_clean(state *my_state); sequence_t *model_label_generate_sequences(model* mo, int seed, int global_len, long seq_number, int Tmax);/** Copies a given state. Allocates the necessary memory. @author Peter Pipenbacher @return copy of the state @param my_state: state to copy */#if 0 state* state_copy(state *my_state);#endif /** Copies a given state to a given destination. @author Peter Pipenbacher @param source: state to copy @param dest: destination */#if 0 void state_copy_to(state *source, state* dest);#endif #ifdef __cplusplus}#endif#endif/*@} (Doc++-Group: model) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -