# cirq.experiments.purity_from_probabilities

Purity estimator from speckle purity benchmarking.

Estimates purity from empirical probabilities of observed bitstrings.

This estimator assumes that the circuit used in experiment is sufficiently scrambling that its output probabilities follow the Porter-Thomas distribution. This assumption holds for typical instances of random quantum circuits of sufficient depth.

The state resulting from the experimental implementation of the circuit is modeled as

``````ρ = p |𝜓⟩⟨𝜓|  + (1 - p) I / D
``````

where |𝜓⟩ is a pure state, I / D is the maximally mixed state, and p is between 0 and 1. The purity of this state is given by p**2. If p = 1, then the bitstring probabilities are modeled as being drawn from the Porter-Thomas distribution, with probability density function given by

``````f(x) = (D - 1) (1 - x)**(D - 2).
``````

The mean of this distribution is 1 / D and its variance is (D - 1) / [D2 (D + 1)]. In general, the variance of the distribution is multipled by p2. Therefore, the purity can be computed by dividing the variance of the empirical probabilities by the Porter-Thomas variance (D - 1) / [D**2 (D + 1)].

`hilbert_space_dimension` Dimension of the Hilbert space on which the quantum circuits acts.
`probabilities` Empirical probabilities of bitstrings observed in experiment.

Estimate of the purity of the state resulting from the experimental implementation of a quantum circuit.

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