ELIFE-ASU / Inform

A cross platform C library for information analysis of dynamical systems

Home Page:https://elife-asu.github.io/Inform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 ith state to the jth state, (given the system is in the ith state).

@jakehanson What do you think of this suggestion?