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

37 lines
1.8 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_counts
description: API reference for qiskit.result.marginal_counts
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.result.marginal_counts
---
# qiskit.result.marginal\_counts
<Function id="qiskit.result.marginal_counts" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.21/qiskit/result/utils.py" signature="marginal_counts(result, indices=None, inplace=False, format_marginal=False, marginalize_memory=True)">
Marginalize counts from an experiment over some indices of interest.
**Parameters**
* **result** (`Union`\[`dict`, [`Result`](qiskit.result.Result "qiskit.result.result.Result")]) result to be marginalized (a Result object or a dict(str, int) of counts).
* **indices** (`Optional`\[`List`\[`int`]]) The bit positions of interest to marginalize over. If `None` (default), do not marginalize at all.
* **inplace** (`bool`) Default: False. Operates on the original Result argument if True, leading to loss of original Job Result. It has no effect if `result` is a dict.
* **format\_marginal** (`bool`) Default: False. If True, takes the output of marginalize and formats it with placeholders between cregs and for non-indices.
* **marginalize\_memory** (`Optional`\[`bool`]) If True, then also marginalize the memory field (if present). If False, remove the memory field from the result. If None, leave the memory field as is.
**Returns**
**A Result object or a dictionary with**
the observed counts, marginalized to only account for frequency of observations of bits of interest.
**Return type**
[Result](qiskit.result.Result "qiskit.result.Result") or dict(str, int)
**Raises**
**QiskitError** in case of invalid indices to marginalize over.
</Function>