entropy(prob)

import linguistics.probability-1

Calculate the entropy (expected surprisal).

import linguistics.probability-1;
entropy([1/16, 1/2, 1/4])
probThe list of probabilities of which the entropy is to be calculated.
return valueThe entropy of the given probabilities.

The function takes a list of probabilities as its argument, and returns the entropy.

The logarithm used for calculating entropy is base 2.