Function get_implied_distribution

Source
pub fn get_implied_distribution(
    f: impl Fn(u64) -> usize,
) -> (Vec<(u64, usize)>, Vec<f64>)
Expand description

Given the len function of a code, generates data that allows to sample its implied distribution, i.e. a code-word with length l has probability 2^(-l).

This code works only with monotonic non decreasing len functions.

Returns two vectors, the first one contains the input values where the function changes value and the code length at that point. The second vector contains the probability of each code length.

Since we cannot write more than 64 bits at once, the codes are limited to 128 bits.