MCPcopy Create free account
hub / github.com/bamler-lab/constriction / discrete_distribution

Function discrete_distribution

tests/python/test_docexamples.py:710–723  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

708 coder.decode(model, model_parameters[:, 0].copy(), model_parameters[:, 1].copy()) == symbols)
709
710 def discrete_distribution():
711 model = constriction.stream.model.CustomModel(
712 lambda x, params: scipy.stats.binom.cdf(x, n=10, p=params),
713 lambda x, params: scipy.stats.binom.ppf(x, n=10, p=params),
714 0, 10)
715
716 success_probabilities = np.array([0.3, 0.7, 0.2, 0.6])
717
718 symbols = np.array([4, 8, 1, 5], dtype=np.int32)
719 coder = constriction.stream.stack.AnsCoder()
720 coder.encode_reverse(
721 symbols, model, success_probabilities)
722 assert np.all(
723 coder.decode(model, success_probabilities) == symbols)
724
725 fixed_model_params()
726 variable_model_params()

Callers 3

test_custom_model_ansFunction · 0.70
test_custom_model_rangeFunction · 0.70

Calls 8

encode_reverseMethod · 0.95
decodeMethod · 0.95
encodeMethod · 0.95
get_compressedMethod · 0.95
decodeMethod · 0.95
decodeMethod · 0.95
encode_reverseMethod · 0.95
get_dataMethod · 0.95

Tested by

no test coverage detected