def verify_model(model, hist):
# 15-bit integers.
for p in model:
if not type(p) is int:
raise Exception("model does not consist of 15-bit integers")
if not 0 <= p <= 0x7fff:
raise Exception("model does not consist of 15-bit integers")
# Sums to 1.
if sum(model) != 0x7fff:
raise Exception("cumulative probability of model is not 1")
# Zero must stay accurate.
for m, h in zip(model, hist):
if (m == 0 and h != 0) or (m != 0 and h == 0):