def Energy_Estimate(data, pauli_list):
"""Compute expectation value of a list of diagonal Paulis with
coefficients given measurement data. If somePaulis are non-diagonal
appropriate post-rotations had to be performed in the collection of data
Args:
data : output of the execution of a quantum program
pauli_list : list of [coeff, Pauli]
Returns:
The expectation value
"""
energy = 0
if np.ndim(pauli_list) == 1:
energy = pauli_list[0] * measure_pauli_z(data, pauli_list[1])
else:
for p in pauli_list:
energy += p[0] * measure_pauli_z(data, p[1])
return energy
评论列表
文章目录