How do I compute the approximate entropy of a bit string?

前端 未结 7 2060
梦如初夏
梦如初夏 2020-12-07 20:46

Is there a standard way to do this?

Googling -- \"approximate entropy\" bits -- uncovers multiple academic papers but I\'d like to just find a chunk of pseudocode de

7条回答
  •  囚心锁ツ
    2020-12-07 21:01

    Entropy is not a property of the string you got, but of the strings you could have obtained instead. In other words, it qualifies the process by which the string was generated.

    In the simple case, you get one string among a set of N possible strings, where each string has the same probability of being chosen than every other, i.e. 1/N. In the situation, the string is said to have an entropy of N. The entropy is often expressed in bits, which is a logarithmic scale: an entropy of "n bits" is an entropy equal to 2n.

    For instance: I like to generate my passwords as two lowercase letters, then two digits, then two lowercase letters, and finally two digits (e.g. va85mw24). Letters and digits are chosen randomly, uniformly, and independently of each other. This process may produce 26*26*10*10*26*26*10*10 = 4569760000 distinct passwords, and all these passwords have equal chances to be selected. The entropy of such a password is then 4569760000, which means about 32.1 bits.

提交回复
热议问题