rand.random_povm¶
Generates a random POVM.
Functions¶
|
Generate random positive operator valued measurements (POVMs) [1]. |
Module Contents¶
- rand.random_povm.random_povm(dim, num_inputs, num_outputs, seed=None)¶
Generate random positive operator valued measurements (POVMs) [1].
Examples
We can generate a set of dim-by-dim POVMs consisting of a specific dimension along with a given number of measurement inputs and measurement outputs. As an example, we can construct a random set of \(2\)-by-\(2\) POVMs of dimension with \(2\) inputs and \(2\) outputs.
import numpy as np from toqito.rand import random_povm dim, num_inputs, num_outputs = 2, 2, 2 povms = random_povm(dim, num_inputs, num_outputs) povms
array([[[[ 0.50140234+0.j, 0.49859766+0.j], [ 0.88302845+0.j, 0.11697155+0.j]], [[ 0.38086181+0.j, -0.38086181+0.j], [ 0.20828119+0.j, -0.20828119+0.j]]], [[[ 0.38086181+0.j, -0.38086181+0.j], [ 0.20828119+0.j, -0.20828119+0.j]], [[ 0.29407579+0.j, 0.70592421+0.j], [ 0.60164344+0.j, 0.39835656+0.j]]]])
We can verify that this constitutes a valid set of POVM elements as checking that these operators all sum to the identity operator.
np.round(povms[:, :, 0, 0] + povms[:, :, 0, 1])
array([[1.+0.j, 0.+0.j], [0.+0.j, 1.+0.j]])
It is also possible to add a seed for reproducibility.
import numpy as np from toqito.rand import random_povm dim, num_inputs, num_outputs = 2, 2, 2 povms = random_povm(dim, num_inputs, num_outputs, seed=42) povms
array([[[[ 0.22988028+0.j, 0.77011972+0.j], [ 0.45021752+0.j, 0.54978248+0.j]], [[-0.23938341+0.j, 0.23938341+0.j], [ 0.32542956+0.j, -0.32542956+0.j]]], [[[-0.23938341+0.j, 0.23938341+0.j], [ 0.32542956+0.j, -0.32542956+0.j]], [[ 0.83184406+0.j, 0.16815594+0.j], [ 0.61323275+0.j, 0.38676725+0.j]]]])
We can once again verify that this constitutes a valid set of POVM elements as checking that these operators all sum to the identity operator.
References
- Parameters:
dim (int) – The dimensions of the measurements.
num_inputs (int) – The number of inputs for the measurement.
num_outputs (int) – The number of outputs for the measurement.
seed (int | None) – A seed used to instantiate numpy’s random number generator.
- Returns:
A set of dim-by-dim POVMs of shape (dim, dim, num_inputs, num_outputs).
- Return type:
numpy.ndarray