Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify order of measurements for locally-biased classical shadows #107

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions docs/tutorials/randomized_measurements.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"source": [
"from povm_toolbox.library import ClassicalShadows\n",
"\n",
"# By default, the Classical Shadows (CS) measurement uses X,Y,Z measurements with equal probability.\n",
"# By default, the Classical Shadows (CS) measurement uses Z-,X-,Y-measurements with equal probability.\n",
"cs_implementation = ClassicalShadows(num_qubits=num_qubits, seed=23)\n",
"# Define the default shot budget.\n",
"cs_shots = 4096\n",
Expand All @@ -150,15 +150,23 @@
"source": [
"from povm_toolbox.library import LocallyBiasedClassicalShadows\n",
"\n",
"# Set the distributions of the shots among the X,Y,Z measurements.\n",
"# Set the distributions of the shots among the Z-,X-,Y-measurements (in this order).\n",
"bias = np.array(\n",
" [\n",
" [0.0000000028, 0.4408677642, 0.5591322330], # bias for first qubit\n",
" [0.1989721524, 0.3190601952, 0.4819676524], # bias for second qubit\n",
" [\n",
" 0.0000000028, # bias for Z-measurements on first qubit\n",
" 0.4408677642, # bias for X-measurements on first qubit\n",
" 0.5591322330, # bias for Y-measurements on first qubit\n",
" ],\n",
" [\n",
" 0.1989721524, # bias for Z-measurements on second qubit\n",
" 0.3190601952, # bias for X-measurements on second qubit\n",
" 0.4819676524, # bias for Y-measurements on second qubit\n",
" ],\n",
" ]\n",
")\n",
"\n",
"# The Locally-Biased Classical Shadows (LBCS) measurement uses X,Y,Z measurements with different probabilities.\n",
"# The Locally-Biased Classical Shadows (LBCS) measurement uses Z-,X-,Y-measurements with different probabilities.\n",
"lbcs_implementation = LocallyBiasedClassicalShadows(num_qubits=num_qubits, bias=bias, seed=24)\n",
"# Define the default shot budget.\n",
"lbcs_shots = 4096\n",
Expand Down
6 changes: 4 additions & 2 deletions povm_toolbox/library/locally_biased_classical_shadows.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def __init__(
num_qubits: the number of qubits.
bias: can be either 1D or 2D. If 1D, it should contain float values indicating the bias
for measuring in each of the PVMs. I.e., its length equals the number of PVMs (3).
These floats should sum to 1. If 2D, it will have a new set of biases for each
qubit.
The first bias corresponds to the Z-measurement, the second bias to the
X-measurement and the third bias to the Y-measurement. These floats should sum to 1.
If 2D, the expected shape of the array is ``(num_qubits, 3)`` and a new set of
biases will be set for each qubit.
measurement_layout: optional list of indices specifying on which qubits the POVM acts.
See :attr:`.measurement_layout` for more details.
measurement_twirl: whether to randomly twirl the measurements. For each single-qubit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def __init__(
num_qubits: the number of qubits.
bias: can be either 1D or 2D. If 1D, it should contain float values indicating the bias
for measuring in each of the PVMs. I.e., its length equals the number of PVMs (3).
These floats should sum to 1. If 2D, it will have a new set of biases for each
qubit.
These floats should sum to 1. If 2D, the expected shape of the array is
``(num_qubits, 3)`` and a new set of biases will be set for each qubit.
angles: can be either 1D or 2D. If 1D, it should be of length 3 and contain float values
to indicate the three Euler angles to rotate the locally-biased classical shadows
(LBCS) measurement in the Bloch sphere representation. If 2D, it will have a new set
Expand Down
4 changes: 2 additions & 2 deletions povm_toolbox/library/randomized_projective_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def __init__(
num_qubits: the number of qubits.
bias: can be either 1D or 2D. If 1D, it should contain float values indicating the bias
for measuring in each of the PVMs. I.e., its length equals the number of PVMs.
These floats should sum to 1. If 2D, it will have a new set of biases for each
qubit.
These floats should sum to 1. If 2D, the expected shape of the array is
``(num_qubits, num_pvms)`` and a new set of biases will be set for each qubit.
angles: can be either 1D or 2D. If 1D, it should be a flatten array containing float
values to indicate the different angles of each PVM. I.e. its length equals two
times the number of PVMs (since we have 2 angles per PVM). If 2D, it will have a new
Expand Down
Loading