Measurement scenario module

Module description

The Measurement Scenario class (necessary for the EmpiricalModel class) is storing the variables linked to an experiment described by Abramsky and Brandenburger.

Module documentation

Contextual scenario for Contextual Fraction

class contextuality.measurement_scenario.GeneralizedMeasurementScenario(X, M, O, ME, PE)
Parameters:
  • X (List[int | Symbol | str])

  • M (List[List[int | Symbol | str]])

  • O (List[int])

  • ME (Dict[str | Symbol | Expr, str | Symbol | Expr])

  • PE (Dict[str | Symbol | Expr, str | Symbol | Expr])

__init__(X, M, O, ME, PE)

Initialize the measurement scenario.

Parameters:
  • X (List[int | Symbol | str]) – Set of measurement labels. Must be a list of integers or symbols.

  • M (List[List[int | Symbol | str]]) – Covering family of X. Set of subsets of X. List of measurement contexts.

  • O (List[int]) – List of outcomes. It is assumed that all measurements have the same possible outcomes.

  • ME (Dict[str | Symbol | Expr, str | Symbol | Expr])

  • PE (Dict[str | Symbol | Expr, str | Symbol | Expr])

property incidence_matrix: ndarray

Accessor for the incidence matrix.

Returns:

the incidence matrix

class contextuality.measurement_scenario.MeasurementScenario(X, M, O)

Class for Contextual Scenario.

Parameters:
  • X (List[int | Symbol | str])

  • M (List[List[int | Symbol | str]])

  • O (List[int])

__init__(X, M, O)

Initialize the measurement scenario.

Parameters:
  • X (List[int | Symbol | str]) – Set of measurement labels. Must be a list of integers or symbols.

  • M (List[List[int | Symbol | str]]) – Covering family of X. Set of subsets of X. List of measurement contexts.

  • O (List[int]) – List of outcomes. It is assumed that all measurements have the same possible outcomes.

Return type:

None

property all_outcomes: List[Tuple[int]]

Give all the outcomes of the contexts of the measurement scenario. WARNING: This assumes that all the contexts have same length.

Returns:

A list of all the outcomes for a given context.

Example:

>>> ms = MeasurementScenarioImplementations.CHSH()
>>> ms.all_outcomes
[(0, 0), (0, 1), (1, 0), (1, 1)]
generate_deterministic(positions)

Generates a deterministic empirical model from the given positions.

Parameters:

positions (Iterable[int]) – List of ints to indicate the positions of the “1” in each context.

Returns:

A numpy array representing the deterministic empirical model.

Return type:

ndarray

property incidence_matrix: ndarray

Accessor for the incidence matrix.

Returns:

the incidence matrix

property incidence_matrix_constrained: ndarray

Accessor for an incidence matrix that takes into account incompatible measurements.

Returns:

the incidence matrix

Return type:

np.ndarray

property outcomes_global: List[List[int]]

Gives all the possible outcomes attributions.

Returns:

A list of lists of attributions.

Example: >>> ms = MeasurementScenarioImplementations.CHSH() >>> ms.outcomes_global [0,0,0,0], [0,0,0,1], [0,0,1,0], [0,0,1,1], [0,1,0,0], …

class contextuality.measurement_scenario.MeasurementScenarioImplementations

Director for many implementations of the MeasurementScenario, and to be DRY.

static CHSH()

Generates the CHSH MeasurementScenario class.

Return type:

MeasurementScenario

static KCBS()

Generates the KCBS MeasurementScenario class.

Return type:

MeasurementScenario

static PeresMermin()

Generates the Peres Mermin MeasurementScenario class.

Return type:

MeasurementScenario