-
Notifications
You must be signed in to change notification settings - Fork 3
/
MarkovChain.h
27 lines (23 loc) · 1.32 KB
/
MarkovChain.h
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
/*
MarkovChain.h - Library for using Markov Chains in Arduino
*/
#ifndef MarkovChain_h
#define MarkovChain_h
#include "Arduino.h"
class MarkovChain
{
public:
int* getFirstStates(char* elements, int numOfElements, char** sequences, int rows);
int counterTransitionsInSequence(char expectedFrom, char expectedTo, char sequence [], int numOfElements);
int countElementsInSequence(char * sequence);
int** createTransitionMatrix(char elements [], int numOfElements, char ** sequences, int numSequences);
int* countRowsTotals(int** transitionMatrix, int numOfElements);
double** createTransitionProbabilityMatrix(int* rowsTotals, int** transitionMatrix, int numOfElements);
double * calculateFirstStatesProbabilities (char* elements, int numOfElements, char** sequences, int numOfSecuences);
//******************************************************************************************
//******* Only the following functions are needed to be called to use Markov Chains ********
//******************************************************************************************
double* getNextTransitions(char element, char* elements, int numOfElements, char ** sequences, int numSequences );
double getSequenceProbability(char* sequence, int seqElementsNum, char* elements, int numOfElements, char ** sequences, int numSequences);
};
#endif