def analytical_value_h_shannon(distr, par):
""" Analytical value of the Shannon entropy for the given distribution.
Parameters
----------
distr : str
Name of the distribution.
par : dictionary
Parameters of the distribution. If distr = 'uniform': par["a"],
par["b"], par["l"] <- lxU[a,b]. If distr = 'normal' : par["cov"]
is the covariance matrix.
Returns
-------
h : float
Analytical value of the Shannon entropy.
"""
if distr == 'uniform':
# par = {"a": a, "b": b, "l": l}
h = log(prod(par["b"] - par["a"])) + log(absolute(det(par["l"])))
elif distr == 'normal':
# par = {"cov": c}
dim = par["cov"].shape[0] # =c.shape[1]
h = 1/2 * log((2 * pi * exp(1))**dim * det(par["cov"]))
# = 1/2 * log(det(c)) + d / 2 * log(2*pi) + d / 2
else:
raise Exception('Distribution=?')
return h
x_analytical_values.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录