Skip to content

Marginalize probabilities prior to confusion matrix application #1413

Description

@alecandido

Since the readout confusion matrices applied are only defined per-qubit, they do not mix the probabilities of the states of the other qubits.
Moreover, since we do only support measurements for individual qubits, we can then safely marginalize on all the other qubits spaces prior to the application of the confusion matrix for the single qubit involved in the measurement.

For an individual array of probabilities, the code would look like the following

dims = (3, 3, 3, 3)
p = np.random.rand(np.prod(dims))
probs = p / p.sum()

def marginalize(p: np.ndarray, idx: int, dims: tuple[int, ...]) -> np.ndarray:
    return p.reshape(dims).sum(axis=tuple(i for i in range(len(dims)) if i != idx))

x = marginalize(probs, 2, dims)

Pay attention that this needs to be generalized when applied simultaneously for multiple distributions (as in the results of swept experiments.

Note

We only started applying confusion matrices in #1401

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions