Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.aqua.components.initial_states.Custom

class Custom(num_qubits, state='zero', state_vector=None, circuit=None)

GitHub

The custom initial state.

A custom initial state can be created with this component. It allows a state to be defined in the form of custom probability distribution with the state_vector, or by providing a desired circuit to set the state.

Also state can be used having a few pre-defined initial states for convenience:

  • ‘zero’: configures the state vector with the zero probability distribution, and is effectively equivalent to the Zero initial state.
  • ‘uniform’: This setting configures the state vector with the uniform probability distribution. All the qubits are set in superposition, each of them being initialized with a Hadamard gate, which means that a measurement will have equal probabilities to become 11 or 00.
  • ‘random’: This setting assigns the elements of the state vector according to a random probability distribution.

The custom initial state will be set from the circuit, the state_vector, or state, in that order. For state_vector the provided custom probability distribution will be internally normalized so the total probability represented is 1.01.0.

Parameters

  • num_qubits (int) – Number of qubits, has a minimum value of 1.
  • state (str) – Use a predefined state of (‘zero’ | ‘uniform’ | ‘random’)
  • state_vector (Union[ndarray, StateFn, None]) – An optional vector of complex or float representing the state as a probability distribution which will be normalized to a total probability of 1 when initializing the qubits. The length of the vector must be 2q2^q, where qq is the num_qubits value. When provided takes precedence over state.
  • circuit (Optional[QuantumCircuit]) – A quantum circuit for the desired initial state. When provided takes precedence over both state_vector and state.

Raises

AquaError – invalid input

__init__

__init__(num_qubits, state='zero', state_vector=None, circuit=None)

Parameters

  • num_qubits (int) – Number of qubits, has a minimum value of 1.
  • state (str) – Use a predefined state of (‘zero’ | ‘uniform’ | ‘random’)
  • state_vector (Union[ndarray, StateFn, None]) – An optional vector of complex or float representing the state as a probability distribution which will be normalized to a total probability of 1 when initializing the qubits. The length of the vector must be 2q2^q, where qq is the num_qubits value. When provided takes precedence over state.
  • circuit (Optional[QuantumCircuit]) – A quantum circuit for the desired initial state. When provided takes precedence over both state_vector and state.

Raises

AquaError – invalid input


Methods

__init__(num_qubits[, state, state_vector, …])type num_qubitsint
construct_circuit([mode, register])Construct the statevector of desired initial state.

Attributes

bitstr

construct_circuit

construct_circuit(mode='circuit', register=None)

Construct the statevector of desired initial state.

Parameters

  • mode – vector or circuit. The vector mode produces the vector. While the circuit constructs the quantum circuit corresponding that vector.
  • register – qubits for circuit construction.

Returns

statevector.

Return type

QuantumCircuit or numpy.ndarray

Raises

AquaError – when mode is not ‘vector’ or ‘circuit’.

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