uniqc.analyzer.draw module#

Visualization utilities for quantum measurement results.

uniqc.analyzer.draw.plot_distribution(measured_result, title='Probability Distribution', figsize=(10, 6))[source]#

Plot a bar chart of the probability distribution with a uniform reference line.

Parameters:
  • measured_result (Dict[str, float] | List[float]) –

    Measurement results in one of two formats:

    • key-value dict: Maps outcome strings to probabilities, e.g. {"00": 0.5, "11": 0.5}.

    • list: Probability vector in computational-basis order, e.g. [0.5, 0, 0, 0.5] for a 2-qubit system.

  • title (str) – Plot title. Defaults to "Probability Distribution".

  • figsize (Tuple[int, int]) – Figure size (width, height) in inches. Defaults to (10, 6).

Raises:

ValueError – If the list length does not correspond to a valid number of qubits (i.e. is not a power of 2).

Return type:

None

Example

>>> from uniqc.analyzer.draw import plot_distribution
>>> # Key-value format
>>> plot_distribution({"00": 0.5, "11": 0.5}, title="Bell State")
>>> # List format (2 qubits)
>>> plot_distribution([0.5, 0, 0, 0.5], title="Bell State")
uniqc.analyzer.draw.plot_histogram(measured_result, title='Measurement Result', figsize=(10, 6))[source]#

Plot a histogram of measurement results.

Parameters:
  • measured_result (Dict[str, float] | List[float]) –

    Measurement results in one of two formats:

    • key-value dict: Maps outcome strings to probabilities, e.g. {"00": 0.5, "11": 0.5}.

    • list: Probability vector in computational-basis order, e.g. [0.5, 0, 0, 0.5] for a 2-qubit system.

  • title (str) – Plot title. Defaults to "Measurement Result".

  • figsize (Tuple[int, int]) – Figure size (width, height) in inches. Defaults to (10, 6).

Raises:

ValueError – If the list length does not correspond to a valid number of qubits (i.e. is not a power of 2).

Return type:

None

Example

>>> from uniqc.analyzer.draw import plot_histogram
>>> # Key-value format
>>> plot_histogram({"00": 0.5, "11": 0.5}, title="Bell State")
>>> # List format (2 qubits)
>>> plot_histogram([0.5, 0, 0, 0.5], title="Bell State")