est_rel_entro_MLE.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:HJW_KL_divergence_estimator 作者: Mathegineer 项目源码 文件源码
def est_entro_MLE(samp):
    """MLE estimate of Shannon entropy (in bits) of input sample

    This function returns a scalar MLE estimate of the entropy of samp when 
    samp is a vector, or returns a row vector containing the MLE estimate of
    each column of samp when samp is a matrix.

    Input:
    ----- samp: a vector or matrix which can only contain integers. The
                 input data type can be any integer types such as uint8/int8/
                 uint16/int16/uint32/int32/uint64/int64, or floating-point
                 such as single/double.
    Output:
    ----- est: the entropy (in bits) of the input vector or that of each
               column of the input matrix. The output data type is double.
    """

    samp = formalize_sample(samp)
    [n, wid] = samp.shape
    n = float(n)

    f = fingerprint(samp)
    prob = np.arange(1, f.shape[0] + 1) / n
    prob_mat = - prob * np.log2(prob)
    return prob_mat.dot(f)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号