下面用于计算序列的熵。是否可以并行化该功能?
def get_lempel_ziv_entropy(message: str) -> float:
i, lib = 1, [message[0]]
while i < len(message):
for j in range(i, len(message)):
message_ = message[i:j + 1]
if message_ not in lib:
lib.append(message_)
break
i = j + 1
return len(lib) / len(message)
梦里花落0921
相关分类