# openfermion.circuits.preprocess_lcu_coefficients_for_reversible_sampling

Prepares data used to perform efficient reversible roulette selection.

Treats the coefficients of unitaries in the linear combination of unitaries decomposition of the Hamiltonian as probabilities in order to decompose them into a list of alternate and keep numerators allowing for an efficient preparation method of a state where the computational basis state :math. `|k>` has an amplitude proportional to the coefficient.

It is guaranteed that following the following sampling process will sample each index k with a probability within epsilon of lcu_coefficients[k] / sum(lcu_coefficients) and also,

1. Uniformly sample an index i from [0, len(lcu_coefficients) - 1].
2. With probability keep_numers[i] / by keep_denom, return i.
3. Otherwise return alternates[i].

`lcu_coefficients` A list of non-negative floats, with the i'th float corresponding to the i'th coefficient of an LCU decomposition of the Hamiltonian (in an ordering determined by the caller).
`epsilon` Absolute error tolerance.

`alternates` `list[int]`

A python list of ints indicating alternative indices that may be switched to after generating a uniform index. The int at offset k is the alternate to use when the initial index is k.

`keep_numers` `list[int]`

A python list of ints indicating the numerators of the probability that the alternative index should be used instead of the initial index.

`sub_bit_precision` `int`

A python int indicating the exponent of the denominator to divide the items in keep_numers by in order to get a probability. The actual denominator is 2**sub_bit_precision.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]