def calc_entropy_for_specipic_t(current_ts, px_i):
"""Calc entropy for specipic t"""
b2 = np.ascontiguousarray(current_ts).view(
np.dtype((np.void, current_ts.dtype.itemsize * current_ts.shape[1])))
unique_array, unique_inverse_t, unique_counts = \
np.unique(b2, return_index=False, return_inverse=True, return_counts=True)
p_current_ts = unique_counts / float(sum(unique_counts))
p_current_ts = np.asarray(p_current_ts, dtype=np.float64).T
H2X = px_i * (-np.sum(p_current_ts * np.log2(p_current_ts)))
return H2X
评论列表
文章目录