Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version


marginal_distribution(counts, indices=None, format_marginal=False)

GitHub(opens in a new tab)

Marginalize counts from an experiment over some indices of interest.

Unlike marginal_counts() this function respects the order of the input indices. If the input indices list is specified then the order the bit indices are specified will be the output order of the bitstrings in the marginalized output.


  • counts (dict) – result to be marginalized
  • indices (Optional[Sequence[int]]) – The bit positions of interest to marginalize over. If None (default), do not marginalize at all.
  • format_marginal (bool) – Default: False. If True, takes the output of marginalize and formats it with placeholders between cregs and for non-indices.


A marginalized dictionary

Return type

dict(str, int)


  • QiskitError – If any value in indices is invalid or the counts dict
  • is invalid.
Was this page helpful?
Report a bug or request content on GitHub.