Skip to main content
A key challenge in quantum computing applications — such as quantum machine learning, finance, and optimization — is efficiently encoding classical data into quantum states. In this tutorial, we’ll load a classical probability distribution (like the normal distribution) into a quantum state. This is a core primitive you’ll reuse across various quantum applications including finance, simulation, and machine learning.
  • Goal: Encode a probability distribution into a quantum state such that measurement outcomes follow the target distribution.
  • Use Case: Financial modeling, probabilistic simulations, quantum generative models.
  • How it works: The square root of the distribution (e.g., Gaussian) is mapped onto quantum amplitudes via state preparation circuits.
Haiqu SDK offers a simple function to load over 100 distributions supported by scipy.stats library. A simple Normal distribution loaded into the register of num qubits can be created by running the following function that initializes the corresponding job as
job = haiqu.distribution_loading(
  name=f"DL norm {num_qubits}q",        # Unique name
  num_qubits=num_qubits,                # Number of qubits
  distribution_name="norm",             # Distribution to load
  interval_start=-3, interval_end=3,    # Interval over which to load
  num_layers=2                          # Precision level
  )
and reading the resulting circuit into the data_loading_gate variable.
data_loading_gate, fidelity = job.result()
Where fidelity indicates the quality of the distribution approximation on ideal QPU. Here, user had to define:
  • name: an identifier for the circuit, which can be used to retrieve it later.
  • distribution_name: the name of the statistical distribution from scipy.stats.
  • interval_start and interval_end: define the beginning and end of a finite positive interval over which the distribution will be discretized and loaded into the quantum state.
  • num_qubits: the number of qubits, which defines the dimensionality of the quantum state. The state will be prepared on a grid of points.
Additionally, user can control advanced parameters, such as: Distribution Hyperparameters (Optional) These follow SciPy’s API:
  • loc (default: 00) → The location/mean of the distribution.
  • scale (default: 11) → Scale or spread, often linked to variance.
  • shape parameters → Distribution-specific extra parameters. Check SciPy docs for details.
State Preparation Hyperparameters
  • num_layers (default: 11) → Number of resulting circuit layers. More layers = better approximation of data or distribution, more gates.
  • truncation_cutoff (default: 1e-6) → A threshold for cutting off low-entanglement gates. Set to None or 0 for no truncation (full entanglement retained).

Distribution Loading Specifications

ParameterDetails
Number of qubitsUp to 1000 qubits
Number of distributions107 different classes of distributions are supported. Check SciPy docs for details.
Runtime1–15 seconds
Runtime scalingLinear scaling with number of qubits
Circuit size (gates count)O(n), n = number of qubits
Circuit depthO(n/2), n = number of qubits
Circuit connectivityLinear
Other circuit properties- No mid-circuit measurements
- Only CNOT and single-qubit rotation gates
- No ancillary qubits
- No post-selection required in state preparation
Returned metricsQuantum state fidelity is returned for the ideal state prepared by the circuit