This project is archived

Qiskit Finance is no longer maintained and this documentation is no longer updated. It is kept online for reference only, and the code it describes may not work with current versions of Qiskit. See the project repository for more information.

UniformDistribution#

class UniformDistribution(num_qubits, name='P(X)')[source]#

Bases: QuantumCircuit

A circuit to encode a discretized uniform distribution in qubit amplitudes.

This simply corresponds to applying Hadamard gates on all qubits.

The probability density function of the discretized uniform distribution on \(N\) values is

\[\mathbb{P}(X = x) = \frac{1}{N}.\]

This circuit considers \(N = 2^n\), where \(n =\) num_qubits and prepares the state

\[\mathcal{P}_X |0\rangle^{\otimes n} = \frac{1}{\sqrt{2^n}} \sum_{x=0}^{2^n - 1} |x\rangle\]

Examples

>>> from qiskit_finance.circuit.library.probability_distributions import UniformDistribution
>>> circuit = UniformDistribution(3)
>>> circuit.decompose().draw()
     ┌───┐
q_0: ┤ H ├
     ├───┤
q_1: ┤ H ├
     ├───┤
q_2: ┤ H ├
     └───┘
Parameters:
  • num_qubits (int) – The number of qubits in the circuit, the distribution is uniform over 2 ** num_qubits values.

  • name (str) – The name of the circuit.

Attributes

Methods