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

Distributions for Probabilities

dglmoore opened this issue · comments

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);