|View source on GitHub|
Prepares data used to perform efficient reversible roulette selection.
openfermion.circuits.preprocess_lcu_coefficients_for_reversible_sampling( lcu_coefficients, epsilon )
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
|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,
- Uniformly sample an index i from [0, len(lcu_coefficients) - 1].
- With probability keep_numers[i] / by keep_denom, return i.
- Otherwise return alternates[i].
||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).|
||Absolute error tolerance.|