# Utilities#

Utility functions.

## Bitwise utilities (`circuit_knitting.utils.bitwise`)#

Bitwise utilities.

 `bit_count`(x, /) Count number of set bits.

## Conversion (`circuit_knitting.utils.conversion`)#

Code for converting types of distributions.

 `quasi_to_real`(quasiprobability, mode) Convert a quasi probability to a valid probability distribution. Convert quasiprobability distribution to the nearest probability distribution. `naive_probability_distribution`(quasiprobability) Convert quasiprobability dist to probability dist by zero-ing out negative values. `dict_to_array`(distribution_dict, force_prob) Convert dictionary of shot results to array of distribution.

## Iteration utilities (`circuit_knitting.utils.iteration`)#

Iteration utilities.

 `unique_by_id`(iterable, /) Return unique objects in `iterable`, by identity. `unique_by_eq`(iterable, /) Return unique objects in `iterable`, by equality.

## Metrics (`circuit_knitting.utils.metrics`)#

Functions for comparing array distances.

 `chi2_distance`(target, obs) Measure the Chi-square distance. `MSE`(target, obs) Compute the Mean Squared Error (MSE). `MAPE`(target, obs) Compute the Mean Absolute Percentage Error (MAPE). `cross_entropy`(target, obs) Compute the cross entropy between two distributions. `HOP`(target, obs) Compute the Heavy Output Probability (HOP).

## Observable grouping (`circuit_knitting.utils.observable_grouping`)#

Module for conducting Pauli observable grouping.

 `observables_restricted_to_subsystem`(qubits, ...) Restrict each observable to its support on a given subsystem. `CommutingObservableGroup`(general_observable, ...) Set of mutually qubit-wise commuting observables. `ObservableCollection`(observables, /) Collection of observables organized for efficient taking of measurements.

## Orbital reduction (`circuit_knitting.utils.orbital_reduction`)#

Helper functions for reducing orbitals.

 `reduce_bitstrings`(bitstrings, orbitals_to_reduce) Eliminates the specified orbitals in the bitstrings.

## Simulation (`circuit_knitting.utils.simulation`)#

Simulation of precise measurement outcome probabilities.

 Return each classical outcome along with its precise probability. `ExactSampler`(*[, options]) Sampler which returns exact probabilities for each possible outcome.

## Transforms (`circuit_knitting.utils.transforms`)#

Functions for manipulating quantum circuits.

 `separate_circuit`(circuit[, partition_labels]) Separate the circuit into its disconnected components.
 `SeparatedCircuits`(subcircuits, qubit_map) Named tuple for result of `separate_circuit()`.