Skip to content

Commit b263a9c

Browse files
committed
Added functions to generate random paths from models
1 parent cdc19b2 commit b263a9c

8 files changed

Lines changed: 7547 additions & 5044 deletions

File tree

C_H2MM.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Author: Paul David Harris
33
// Purpose: Header files for H2MM and H2MM Viterbi algorithm
44
// Date Created: 13 Feb 2021
5-
// Data Modified: 8 June 2021
5+
// Data Modified: 18 Sept 2021
66

77
#ifdef _WIN32
88
#include <windows.h>
@@ -98,6 +98,14 @@ typedef struct // pwrs is a structure that contains pointers to the A (transmat)
9898
double *Rho; // the Rho array, as defined in H2MM
9999
} pwrs;
100100

101+
typedef struct // pwrs is a structure that contains pointers to the A (transmat) and Rho arrays, plus information on dimensions and which values are to be calculated
102+
{
103+
size_t max_pow; // maximum power, the maximum delta in the data set
104+
size_t sj; // note that this is also the stride for the delta t in the A array
105+
size_t sk; // note that this is also the number of states
106+
double *A; // the A array, contains the powers of the tranistion probability matrix
107+
} trpow;
108+
101109
// viterbi.c structures
102110

103111
// structure identifies a burst, and its viterbi values
@@ -184,3 +192,15 @@ int viterbi(unsigned long num_bursts, unsigned long *burst_sizes, unsigned long
184192
temps* burst_read(char *fname, size_t *n); // read burst data from a .txt file
185193

186194
h2mm_mod* h2mm_read(char *fname); // read h2mm model from .txt file
195+
196+
// simulation functions
197+
198+
void cumsum(unsigned long len, double* arr, double* dest); // calculate the cumulative sum of an array
199+
200+
unsigned long randchoice(unsigned long len, double* arr); // select a random set index within range len, based on array arr
201+
202+
int statepath(h2mm_mod* model, unsigned long lent, unsigned long* path, unsigned int seed); // generate random statepath based on model, with equally spaced times
203+
204+
int sparsestatepath(h2mm_mod* model, unsigned long lent, unsigned long long* times, unsigned long* path, unsigned int seed); // generate random statepath of sparsely spaced times
205+
206+
int phpathgen(h2mm_mod* model, unsigned long lent, unsigned long* path, unsigned long* traj, unsigned int seed); // generate random set of detectors based on given statepath

0 commit comments

Comments
 (0)