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

Function discrete_distribution

tests/python/test_docexamples_f32.py:712–725  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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