Skip to content

Commit

Permalink
replace statistics.mean with numpy.mean
Browse files Browse the repository at this point in the history
  • Loading branch information
FarLab committed Nov 6, 2024
1 parent b751915 commit 9891006
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions docs/source/examples/lre-zne-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ for circuit in circuits:
```

```{code-cell} ipython3
from statistics import mean
import numpy as np
# The theoretical value for the probability of measuring 0 when taking
# an average over all the rotated rb circuits.
p = lambda theta: 1 - (2/3) * np.sin(theta/2)**2
print(f'Average error for noisy values: {abs(mean(noisy_values) - p(0.7))}')
print(f'Average error for ideal values: {abs(mean(ideal_values) - p(0.7))}')
print(f'Average error for noisy values: {abs(np.mean(noisy_values) - p(0.7))}')
print(f'Average error for ideal values: {abs(np.mean(ideal_values) - p(0.7))}')
```

For the ideal values we still see a small error, because we are only taking the average over 50 rotated randomized benchmarking circuits, so there will be noise due to randomness.
Expand Down Expand Up @@ -111,8 +110,8 @@ for circuit in circuits:
```

```{code-cell} ipython3
error_lre = abs(mean(mitigated_values_lre) - p(0.7))
error_zne = abs(mean(mitigated_values_zne) - p(0.7))
error_lre = abs(np.mean(mitigated_values_lre) - p(0.7))
error_zne = abs(np.mean(mitigated_values_zne) - p(0.7))
print(f'Average error of mitigated values using LRE: {error_lre}')
print(f'Average error of mitigated values using ZNE: {error_zne}')
Expand Down

0 comments on commit 9891006

Please sign in to comment.