class MarginalizeCounts(qubits_to_keep, validate=True)[source]

A data action to marginalize count dictionaries.

This data action takes a count dictionary and returns a new count dictionary that is marginalized over a set of specified qubits. For example, given the count dictionary {"010": 1, "110": 10, "100": 100} this node will return the count dictionary {"10": 11, "00": 100} when marginalized over qubit 2.


This data action can be used to discard one or more qubits in the counts dictionary. This is, for example, useful when processing two-qubit restless experiments but can be used in a more general context. In composite experiments the counts marginalization is already done in the data container.

Initialize a counts marginalization node.

  • qubits_to_keep (Set[int]) – A set of qubits to retain during the marginalization process.

  • validate (bool) – If set to False the DataAction will not validate its input.



Call the data action of this node on the data.


data (ndarray) – A numpy array with arbitrary dtype. If the elements are ufloat objects consisting of a nominal value and a standard error, then the error propagation is done automatically.


The processed data.

Return type: