tket
tket copied to clipboard
Add new `get_operator_distribution` utils method
The idea would be to create a new utils method that takes the same arguments as get_operator_expectation_value but returns either an EmpiricalDistribution or ProbabilityDistribution instead.
This would allow us to easily calculate statistics such as the variance of a particular observable.
We could also update get_operator_expectation_value to use this method internally.
Would this also account for correlations between measurements in a commuting set?
Would this also account for correlations between measurements in a commuting set?
I'm not sure what you mean?
But as I think about it, I'm not sure the proposal as formulated above is quite coherent. There would need to be one further argument to get_operator_distribution(), which is a callable mapping bit strings to (real or complex) numbers. It would then return you a distribution modelling the random process where we: choose a random Pauli string from the QPO; run the circuit with those Paulis appended to obtain a bit string; apply the callable; and then multiply by the coefficient of the Pauli string in the QPO. For the special case of get_operator_expectation_value(), the callable would map a bit string to +1 if it has an even number of 1s and -1 otherwise; and it would then return the expectation value of that distribution.
Does this make sense? Is it useful?
Generally we could have all sorts of ways to compute values for an observable, so we prefer more low level support to do this rather than one ready made function. However, if there is a solid method that gives the variance of the mean alongside the mean, that would be useful. At the moment, we calculate variance trivially from the mean, but for terms measured together for example eq 4 in https://arxiv.org/pdf/2004.06252v1.pdf is more accurate. (this paper also have some pauli sampling strategies, I wonder if you could have a simple API for a get_operator_distribution that could cover these strategies)
I cant work it out if your proposed method could account for the covariance term in eq 4, maybe if we sample the paulis taking into account if they are measured together or not?
At the moment, we calculate variance trivially from the mean
Using get_operator_expectaion_value()? I don't see how that's possible... or do you not use that method at all, but just sample the circuits and compute the variance from the results?
I'm actually not sure what the most useful API for pytket to provide is here.
We could not use get_operator_expectaion_value, we had to implement our own and for each pauli we calculate the mean and the variance (that happens to be 1-mean^2, but Iakov I think calculated the variance directly from the distribution as well)
Low priority for now. Need to work out what if any new method would actually be useful here.
Intrestingly there's a get_operator_variance method in pytket-braket which isn't in pytket.utils.
This issue has been automatically marked as stale.