ELIFE-ASU / Inform

A cross platform C library for information analysis of dynamical systems
https://elife-asu.github.io/Inform
MIT License
23 stars 3 forks source link

Add Conditional Entropy #12

Closed dglmoore closed 8 years ago

dglmoore commented 8 years ago

As a generalization of entropy rate, it would be able to compute the conditional entropy between two timeseries.

Proposed API:

double inform_conditional_entropy(int const *xs, int const *ys, size_t n,
    int bx, int by, double b, inform_error *err);

double *inform_local_conditional_entropy(int const *xs, int const *ys, size_t n,
    int bx, int by, double b, double *lce, inform_error *err)

Example Usage:

#define N 9

int xs[N] = {0,0,1,1,1,1,0,0,0};
int ys[N] = {1,0,0,1,0,0,1,0,0};

inform_error err = INFORM_SUCCESS;
inform_conditional_entropy(xs, ys, N, 2, 2, 2.0, &err); // == 0.899985
inform_conditional_entropy(ys, xs, N, 2, 2, 2.0, &err); // == 0.972765

double lce[N];
inform_conditional_entropy(xs, ys, N, 2, 2, 2.0, lce, &err); // == lce
// lce == {1.322 0.737, 0.415, 2.000,  0.415, 0.415, 1.322, 0.737, 0.737}
inform_conditional_entropy(ys, xs, N, 2, 2, 2.0, lce, &err); // == lce
// lce == {0.585, 1.000, 1.000, 1.585, 1.000, 1.000, 0.585, 1.000, 1.000}