Expressed as a formula (*):
m’ = Sum over k of count(T, k)/len(T)
m = 1/m’ if m’ != 0
Sample python code (right-click and use ‘save as’): js_measure.tgz
(*) Oh for latex!