qiskit-documentation/docs/api/qiskit/0.37/qiskit.result.marginal_dist...

36 lines
1.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: marginal_distribution
description: API reference for qiskit.result.marginal_distribution
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.result.marginal_distribution
---
# qiskit.result.marginal\_distribution
<Function id="qiskit.result.marginal_distribution" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.21/qiskit/result/utils.py" signature="marginal_distribution(counts, indices=None, format_marginal=False)">
Marginalize counts from an experiment over some indices of interest.
Unlike [`marginal_counts()`](qiskit.result.marginal_counts "qiskit.result.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.
**Parameters**
* **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.
**Returns**
A marginalized dictionary
**Return type**
dict(str, int)
**Raises**
* **QiskitError** If any value in `indices` is invalid or the `counts` dict
* **is invalid.**
</Function>