# Calculating variance among the states under superposition

I wonder if it is possible to calculate (or estimates) variance among the quantum states under superposition, with respect to their values in the computational basis.

For example, a simple 2-qubit system with the Hadamard operators applied to both of them will create $$|00\rangle, |01\rangle, |10\rangle,$$ and $$|11\rangle$$ with an equal probability amplitude. The integer representation of these states are, respectively, $$0$$, $$1$$, $$2$$, and $$3$$. Using the equation $$s^2=\sum_{i=1}^{n}(x_i-\mu)^2/(n-1)$$, their sample variance is $$1.666667$$.

Can we find this by using a quantum algorithm, perhaps more efficiently than classically calculating it?

• How exactly are you defining the variance? Are you using the amplitudes of each state to define a probability distribution on the labels of the states and then taking the variance of that, or something else? Jan 13 at 16:24
• @Sam Jaques I mean the variance of the integer representation, converted from the bit values of the states. To be exact, with a target state ket(T) given, I would like to know if it is possible to calculate the sum of its "distances" from every other state in terms of its integer value. For example, with two qubits under superposition, suppose I have a target qubit ket(11), whose integer value is 3, and other states with 0, 1, and 2. I would like to know if it is possible to calculate abs[(3-0) + (3-1) + (3-2)], or (3-0)^2 + (3-1)^2 + (3-2)^2. Jan 13 at 16:43
• You've defined $s^2$ on equal superpositions, but it isn't clear how the amplitudes should affect the result. What output do you expect for a state like $\sqrt{1-10^{-100}}|00\rangle+10^{-50}|10\rangle$? Would it be $s^2\approx 0$ or $s^2\approx 2$ or something else? Note that distinguishing between zero amplitude and non-zero amplitude requires infinite precision and is therefore impossible in practice. Jan 13 at 17:10
• @Adam Zalcman I have been thinking of a HHL-like procedure, i.e. the output I want (2 in the case you mentioned) is approximately encoded to the amplitude of an arbitrary or ancilla qubit so that I can evaluate it probabilistically with multiple measurements. What I want to figure out is whether the output tends to increase or decrease with different target states, so it does not have to be highly precise. Jan 13 at 17:52