deltakit.decode.utils.generate_expectation_data#

deltakit.decode.utils.generate_expectation_data(samples: Iterable[Iterable[int]], only_even: bool = False, only_odd: bool = False, max_degree: int = 2, num_processes: int = 1) dict[frozenset[int], float]#

Generates the <Xi>, <Xj>, <Xij> etc expectation values for deriving Pij probabilities.

You may provide a collection or generator as input for samples. In the case of a generator, you must set num_processes=1 as multiprocessing is not supported for samples of generator type.

Parameters:
  • samples (Iterable[Iterable[int]]) – Iterable of iterable of integers signifying which detectors lit up in that shot.

  • only_even (bool) – Boolean to specify whether only the even-indexed samples should be used to generate expectation data.

  • only_odd (bool) – Boolean to specify whether only the odd-indexed samples should be used to generate expectation data.

  • max_degree (int) – Maximum degree hyperedges to be considered. For instance, if a sample contains 4 detector events, and max_degree is set to 4, the program will consider a degree 4 hyperedge consisting of the 4 present detectors. Default value is 2.

  • num_processes (int) – Number of processes across which to distribute the data to parallelise the task. Default value is 1. Value of -1 will use all available cores.

Returns:

The keys are the pairs of detectors that were observed firing together. The frequency of a single detector firing is stored as a tuple of the single detector index, e.g, detector 1 is (1,). The float value represents the expectation value of the given pair of detectors firing.

Return type:

PijData