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

Distributions for Probabilities #47

Closed dglmoore closed 7 years ago

dglmoore commented 7 years ago

Sometimes we'd like to be able to use the functionality of Inform given an known probability distribution rather than one inferred from time series data. To that end, we need a function to construct a distribution which reproduces the original probabilities up to some tolerance.

This has already been done in PyInform by @jakehanson.

Proposed API

EXPORT inform_dist *inform_dist_estimated(double *probs, size_t n, double tol);

Example Usage

double probs[3] = {0.5, 0.2, 0.3};
inform_dist *dist = inform_dist_estimated(probs, 3, 1e-6);
assert(dist->counts == 10);
assert(inform_dist_get(dist, 0) == 5);
assert(inform_dist_get(dist, 1) == 2);
assert(inform_dist_get(dist, 2) == 3);