Create a "Transition Probability Matrix" Function
dglmoore opened this issue · comments
Implementations of Effective Information would benefit from a function which computes transition probability matrices: a matrix encoding the probability of state transitions.
Proposed API
EXPORT double *inform_tpm(int const *series, size_t n, size_t m, int b, double *tpm,
inform_error *err);
Example Usage
#include <inform/tpm.h>
#include <stdio.h>
int main()
{
int series[13] = {0,0,1,0,1,0,0,1,0,1,0,0,1};
double tpm[4];
inform_error err = INFORM_SUCCESS;
inform_tpm(series, 1, 13, 2, tpm, &err);
if (inform_failed(&err))
{
fprintf(stderr, "an error occurred (%d)", err);
}
else
{
for (size_t i = 0; i < 2; ++i)
{
for (size_t j = 0; j < 2; ++j)
{
printf("%0.3lf ", tpm[2 * i + j]);
}
printf("\n");
}
}
}
This should produce the following output:
0.375 0.627
1.000 0.000
where the (i,j)
th element represents the probability of transitioning from the i
th state to the j
th state, (given the system is in the i
th state).
@jakehanson What do you think of this suggestion?