Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

LogNormalDistribution

LogNormalDistribution(num_qubits, mu=None, sigma=None, bounds=None, upto_diag=False, name='P(X)')

GitHub(opens in a new tab)

Bases: qiskit.circuit.quantumcircuit.QuantumCircuit

A circuit to encode a discretized log-normal distribution in qubit amplitudes.

A random variable XX is log-normal distributed if

log(X)N(μ,σ2)\log(X) \sim \mathcal{N}(\mu, \sigma^2)

for a normal distribution N(μ,σ2)\mathcal{N}(\mu, \sigma^2). The probability density function of the log-normal distribution is defined as

P(X=x)=1x2πσ2e(log(x)μ)2σ2\mathbb{P}(X = x) = \frac{1}{x\sqrt{2\pi\sigma^2}} e^{-\frac{(\log(x) - \mu)^2}{\sigma^2}}
Note

The parameter sigma in this class equals the variance, σ2\sigma^2 and not the standard deviation. This is for consistency with multivariate distributions, where the uppercase sigma, Σ\Sigma, is associated with the covariance.

This circuit considers the discretized version of XX on 2 ** num_qubits equidistant points, xix_i, truncated to bounds. The action of this circuit can be written as

PX0n=i=02n1P(xi)i\mathcal{P}_X |0\rangle^n = \sum_{i=0}^{2^n - 1} \sqrt{\mathbb{P}(x_i)} |i\rangle

where nn is num_qubits.

Note

The circuit loads the square root of the probabilities into the qubit amplitudes such that the sampling probability, which is the square of the amplitude, equals the probability of the distribution.

This circuit is for example used in amplitude estimation applications, such as finance [1, 2], where customer demand or the return of a portfolio could be modelled using a log-normal distribution.

Examples

This class can be used for both univariate and multivariate distributions. >>> mu = [1, 0.9, 0.2] >>> sigma = [[1, -0.2, 0.2], [-0.2, 1, 0.4], [0.2, 0.4, 1]] >>> circuit = LogNormalDistribution([2, 2, 2], mu, sigma) >>> circuit.num_qubits 6

References

[1]: Gacon, J., Zoufal, C., & Woerner, S. (2020).

Quantum-Enhanced Simulation-Based Optimization. arXiv:2005.10780(opens in a new tab)

[2]: Woerner, S., & Egger, D. J. (2018).

Quantum Risk Analysis. arXiv:1806.06893(opens in a new tab)

Parameters

  • num_qubits (Union[int, List[int]]) – The number of qubits used to discretize the random variable. For a 1d random variable, num_qubits is an integer, for multiple dimensions a list of integers indicating the number of qubits to use in each dimension.
  • mu (Union[float, List[float], None]) – The parameter μ\mu of the distribution. Can be either a float for a 1d random variable or a list of floats for a higher dimensional random variable.
  • sigma (Union[float, List[float], None]) – The parameter σ2\sigma^2 or Σ\Sigma, which is the variance or covariance matrix.
  • bounds (Union[Tuple[float, float], List[Tuple[float, float]], None]) – The truncation bounds of the distribution as tuples. For multiple dimensions, bounds is a list of tuples [(low0, high0), (low1, high1), ...]. If None, the bounds are set to (0, 1) for each dimension.
  • upto_diag (bool) – If True, load the square root of the probabilities up to multiplication with a diagonal for a more efficient circuit.
  • name (str) – The name of the circuit.

Attributes

ancillas

Returns a list of ancilla bits in the order that the registers were added.

Return type

List[AncillaQubit]

bounds

Return the bounds of the probability distribution.

Return type

Union[Tuple[float, float], List[Tuple[float, float]]]

calibrations

Return calibration dictionary.

The custom pulse definition of a given gate is of the form

{‘gate_name’: {(qubits, params): schedule}}

Return type

dict

clbits

Returns a list of classical bits in the order that the registers were added.

Return type

List[Clbit]

data

Return the circuit data (instructions and context).

Returns

a list-like object containing the tuples for the circuit’s data.

Each tuple is in the format (instruction, qargs, cargs), where instruction is an Instruction (or subclass) object, qargs is a list of Qubit objects, and cargs is a list of Clbit objects.

Return type

QuantumCircuitData

extension_lib

Default value: 'include "qelib1.inc";'

global_phase

Return the global phase of the circuit in radians.

Return type

Union[ParameterExpression, float]

Default value: 'OPENQASM 2.0;'

instances

Default value: 9

metadata

The user provided metadata associated with the circuit

The metadata for the circuit is a user provided dict of metadata for the circuit. It will not be used to influence the execution or operation of the circuit, but it is expected to be passed between all transforms of the circuit (ie transpilation) and that providers will associate any circuit metadata with the results it returns from execution of that circuit.

Return type

dict

num_ancillas

Return the number of ancilla qubits.

Return type

int

num_clbits

Return number of classical bits.

Return type

int

num_parameters

Convenience function to get the number of parameter objects in the circuit.

Return type

int

num_qubits

Return number of qubits.

Return type

int

parameters

Convenience function to get the parameters defined in the parameter table.

Return type

ParameterView

prefix

Default value: 'circuit'

probabilities

Return the sampling probabilities for the values.

Return type

ndarray

qubits

Returns a list of quantum bits in the order that the registers were added.

Return type

List[Qubit]

values

Return the discretized points of the random variable.

Return type

ndarray

Was this page helpful?
Report a bug or request content on GitHub.