You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
r"""Calculate the shadow bound of the Pauli observables, please refer to the Theorem S1 and Lemma S3 in Huang, H.-Y., R. Kueng, and J. Preskill, 2020, Nat. Phys. 16, 1050.
17
+
r"""Calculate the shadow bound of the Pauli observables, please refer to the Theorem S1 and Lemma S3 in
18
+
Huang, H.-Y., R. Kueng, and J. Preskill, 2020, Nat. Phys. 16, 1050.
18
19
19
20
:param observables: shape = (nq,) or (M, nq), where nq is the number of qubits, M is the number of observables
20
21
:type: Union[Tensor, Sequence[int]]
@@ -25,10 +26,11 @@ def shadow_bound(
25
26
26
27
:return Nk: number of snapshots
27
28
:rtype: int
28
-
:return k: Number of equal parts to split the shadow snapshot states to compute the median of means. k=1 (default) corresponds to simply taking the mean over all shadow snapshot states.
29
+
:return k: Number of equal parts to split the shadow snapshot states to compute the median of means.
30
+
k=1 (default) corresponds to simply taking the mean over all shadow snapshot states.
29
31
:rtype: int
30
32
"""
31
-
count=np.sign(backend.numpy(observables))
33
+
count=np.sign(np.asarray(observables))
32
34
iflen(count.shape) ==1:
33
35
count=count[None, :]
34
36
M=count.shape[0]
@@ -65,7 +67,8 @@ def shadow_snapshots(
65
67
ns, nq=pauli_strings.shape
66
68
if2**nq!=len(psi):
67
69
raiseValueError(
68
-
f"The number of qubits of psi and pauli_strings should be the same, but got {nq} and {int(np.log2(len(psi)))}."
70
+
f"The number of qubits of psi and pauli_strings should be the same, "
:param ps: or one can apply a ps structures instead of x, y, z, e.g. [1, 1, 0, 2, 3, 0] for X_0X_1Y_3Z_4 defaults to None, ps can overwrite x, y and z
231
+
:param ps: or one can apply a ps structures instead of x, y, z, e.g. [1, 1, 0, 2, 3, 0] for X_0X_1Y_3Z_4
232
+
defaults to None, ps can overwrite x, y and z
229
233
:type: Optional[Sequence[int]]
230
-
:param k: Number of equal parts to split the shadow snapshot states to compute the median of means. k=1 (default) corresponds to simply taking the mean over all shadow snapshot states.
234
+
:param k: Number of equal parts to split the shadow snapshot states to compute the median of means.
235
+
k=1 (default) corresponds to simply taking the mean over all shadow snapshot states.
0 commit comments