Given a vector v = (v_1, ...
Given a vector v = (v_1, ... v_d) of d probabilities that sum to one, we find the integer representation (where each int is stored in B bits) as follows:
- Multiply v by 2**B-1. - Compute the total fractional part F = sum_i (v_i - floor(v_i)). - Form x by rounding the F entries of v with the largest fractional parts up to the nearest integer, and the other d-F entries down to the nearest smaller integer.