In general the b-ary entropy of a source S {\displaystyle {\mathcal {S}}} = (S, P) with source alphabet S = {a1, …, an} and discrete probability distribution P = {p1, …, pn} where pi is the probability of ai (say pi = p(ai)) is defined by: