ELIFE-ASU / Inform

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

Multivariate Mutual Information #41

Closed dglmoore closed 7 years ago

dglmoore commented 7 years ago

The current implementation of mutual information can compute the mutual information between two time-series. However, some applications, such as integration measures, require calculating the mutual information between more than two variables.

Proposed API Change

EXPORT double inform_mutual_info(int const *series, size_t l, size_t n, size_t m, int b,
    inform_error *err);
EXPORT double *inform_mutual_info(int const *series, size_t l, size_t n, size_t m, int b,
    double *mi, inform_error *err);

Example Usage

#include <assert.h>
#include <inform/mutual_info.h>
#include <stdio.h>

int main()
{
    int series[5] = {
        0, 1, 1, 0, 1,
        1, 1, 0, 1, 1,
        0, 1, 1, 0, 1,
    }

    inform_error err = INFORM_SUCCESS;
    double mi = inform_mutual_info(series, 3, 1, 5, 2, &err);
    assert(inform_succeeded(&err));
    printf("%0.6lf\n", mi); // 7.828819
}