# cirq.experiments.least_squares_xeb_fidelity_from_probabilities

Least squares fidelity estimator with observable based on probabilities.

Using the notation from the docstring of `least_squares_xeb_fidelity_from_expectations`, this function computes the least squares fidelity estimate when the observable O_U has eigenvalue corresponding to the computational basis state |z⟩ given by g(p(z)), where p(z) = |⟨z|𝜓_U⟩|^2 and g is a function that can be specified. By default, g is the identity function, but other choices, such as the logarithm, are useful. By default, the probability p(z) is actually multiplied by the Hilbert space dimension D, so that the observable is actually g(D * p(z)). This behavior can be disabled by setting `normalize_probabilities` to False.

`hilbert_space_dimension` Dimension of the Hilbert space on which the channel whose fidelity is being estimated is defined.
`observed_probabilities` Ideal probabilities of bitstrings observed in experiments. A list of lists, where each inner list contains the probabilities for a single circuit.
`all_probabilities` Ideal probabilities of all possible bitstrings. A list of lists, where each inner list contains the probabilities for a single circuit, and should have length equal to the Hilbert space dimension. The order of the lists should correspond to that of `observed_probabilities`.
`observable_from_probability` Function that computes the observable from a given probability.
`normalize_probabilities` Whether to multiply the probabilities by the Hilbert space dimension before computing the observable.

A tuple of two values. The first value is the estimated fidelity. The second value is a list of the residuals

``````f (e_U - u_U) - (m_U - u_U)
``````

of the least squares minimization.

[{ "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" }]