Maximum entropy distribution

smoother.MaxEntropy

Computes a maximum entropy distribution given moment constraints. Inherits from Smoother. The only difference is that the fit method is optimized but more restrictive.

Notes

See https://en.wikipedia.org/wiki/Maximum_entropy_probability_distribution#Continuous_case for mathematical detail.

Examples

This example approximates a standard normal distribution.

import matplotlib.pyplot as plt
from smoother import MaxEntropy

dist = MaxEntropy()
mu, sigma2 = 0, 1
dist.fit(-3, 3, [lambda x: x, lambda x: (x-mu)**2], [mu, sigma2])
plt.plot(dist.x, dist.f_x)

Methods

fit(self, lb, ub, moment_funcs, values, num=50) [source]

Parameters: lb : scalar

Lower bound of the distribution.

ub : scalar

Upper bound of the distribution.

moment_funcs : list of callable

List of moment functions. e.g. for the mean, use lambda x: x.

values : list of scalars

List of values the expected value of the moment functions should evaluate to.

num : int, default=50

Number of points on the distribution used for approximation.

Returns: self :