# UniformDistribution¶

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

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

>>> circuit = UniformDistribution(3)
>>> circuit.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

 UniformDistribution.ancillas Returns a list of ancilla bits in the order that the registers were added. UniformDistribution.calibrations Return calibration dictionary. UniformDistribution.clbits Returns a list of classical bits in the order that the registers were added. UniformDistribution.data Return the circuit data (instructions and context). UniformDistribution.extension_lib UniformDistribution.global_phase Return the global phase of the circuit in radians. UniformDistribution.header UniformDistribution.instances UniformDistribution.num_ancillas Return the number of ancilla qubits. UniformDistribution.num_clbits Return number of classical bits. UniformDistribution.num_parameters Convenience function to get the number of parameter objects in the circuit. UniformDistribution.num_qubits Return number of qubits. UniformDistribution.parameters Convenience function to get the parameters defined in the parameter table. UniformDistribution.prefix UniformDistribution.qubits Returns a list of quantum bits in the order that the registers were added.

Methods

 Return indexed operation. Return number of operations in circuit. Register a low-level, custom pulse definition for the given gate. Add registers. UniformDistribution.append(instruction[, …]) Append one or more instructions to the end of the circuit, modifying the circuit in place. UniformDistribution.assign_parameters(param_dict) Assign parameters to new parameters or values. Apply Barrier. UniformDistribution.bind_parameters(value_dict) Assign numeric parameters to values yielding a new circuit. UniformDistribution.cast(value, _type) Best effort to cast value to type. Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits. UniformDistribution.ccx(control_qubit1, …) Apply CCXGate. UniformDistribution.ch(control_qubit, …[, …]) Apply CHGate. Return the current number of instances of this class, useful for auto naming. Return the prefix to use for auto naming. UniformDistribution.cnot(control_qubit, …) Apply CXGate. Append rhs to self if self contains compatible registers. UniformDistribution.compose(other[, qubits, …]) Compose circuit with other circuit or instruction, optionally permuting wires. Control this circuit on num_ctrl_qubits qubits. Copy the circuit. Count each operation kind in the circuit. UniformDistribution.cp(theta, control_qubit, …) Apply CPhaseGate. UniformDistribution.crx(theta, …[, label, …]) Apply CRXGate. UniformDistribution.cry(theta, …[, label, …]) Apply CRYGate. UniformDistribution.crz(theta, …[, label, …]) Apply CRZGate. UniformDistribution.cswap(control_qubit, …) Apply CSwapGate. UniformDistribution.csx(control_qubit, …) Apply CSXGate. UniformDistribution.cu(theta, phi, lam, …) Apply CUGate. UniformDistribution.cu1(theta, …[, label, …]) Apply CU1Gate. UniformDistribution.cu3(theta, phi, lam, …) Apply CU3Gate. UniformDistribution.cx(control_qubit, …[, …]) Apply CXGate. UniformDistribution.cy(control_qubit, …[, …]) Apply CYGate. UniformDistribution.cz(control_qubit, …[, …]) Apply CZGate. UniformDistribution.dcx(qubit1, qubit2) Apply DCXGate. Call a decomposition pass on this circuit, to decompose one level (shallow decompose). UniformDistribution.delay(duration[, qarg, unit]) Apply Delay. Return circuit depth (i.e., length of critical path). UniformDistribution.diag_gate(diag, qubit) Deprecated version of QuantumCircuit.diagonal. UniformDistribution.diagonal(diag, qubit) Attach a diagonal gate to a circuit. UniformDistribution.draw([output, scale, …]) Draw the quantum circuit. Append QuantumCircuit to the right hand side if it contains compatible registers. UniformDistribution.fredkin(control_qubit, …) Apply CSwapGate. Take in a QASM file and generate a QuantumCircuit object. Take in a QASM string and generate a QuantumCircuit object. Apply HGate. UniformDistribution.hamiltonian(operator, …) Apply hamiltonian evolution to to qubits. Test if this circuit has the register r. Apply IGate. Apply IGate. UniformDistribution.initialize(params, qubits) Apply initialize to circuit. Invert (take adjoint of) this circuit. UniformDistribution.iso(isometry, q_input, …) Attach an arbitrary isometry from m to n qubits to a circuit. UniformDistribution.isometry(isometry, …) Attach an arbitrary isometry from m to n qubits to a circuit. UniformDistribution.iswap(qubit1, qubit2) Apply iSwapGate. UniformDistribution.mcmt(gate, …[, …]) Apply a multi-control, multi-target using a generic gate. UniformDistribution.mcp(lam, control_qubits, …) Apply MCPhaseGate. UniformDistribution.mcrx(theta, q_controls, …) Apply Multiple-Controlled X rotation gate UniformDistribution.mcry(theta, q_controls, …) Apply Multiple-Controlled Y rotation gate UniformDistribution.mcrz(lam, q_controls, …) Apply Multiple-Controlled Z rotation gate UniformDistribution.mct(control_qubits, …) Apply MCXGate. Apply MCU1Gate. UniformDistribution.mcx(control_qubits, …) Apply MCXGate. UniformDistribution.measure(qubit, cbit) Measure quantum bit into classical bit (tuples). UniformDistribution.measure_active([inplace]) Adds measurement to all non-idle qubits. UniformDistribution.measure_all([inplace]) Adds measurement to all qubits. DEPRECATED: use circuit.reverse_ops(). UniformDistribution.ms(theta, qubits) Apply MSGate. How many non-entangled subcircuits can the circuit be factored to. Return number of non-local gates (i.e. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. UniformDistribution.p(theta, qubit) Apply PhaseGate. UniformDistribution.power(power[, matrix_power]) Raise this circuit to the power of power. UniformDistribution.qasm([formatted, filename]) Return OpenQASM string. Converts several qubit representations (such as indexes, range, etc.) into a list of qubits. Return the duration between the start and stop time of the first and last instructions, excluding delays, over the supplied qubits. Return the start time of the first instruction, excluding delays, over the supplied qubits. Return the stop time of the last instruction, excluding delays, over the supplied qubits. UniformDistribution.r(theta, phi, qubit) Apply RGate. UniformDistribution.rcccx(control_qubit1, …) Apply RC3XGate. UniformDistribution.rccx(control_qubit1, …) Apply RCCXGate. Removes final measurement on all qubits if they are present. Repeat this circuit reps times. Reset q. Return a circuit with the opposite order of wires. Reverse the circuit by reversing the order of instructions. UniformDistribution.rx(theta, qubit[, label]) Apply RXGate. UniformDistribution.rxx(theta, qubit1, qubit2) Apply RXXGate. UniformDistribution.ry(theta, qubit[, label]) Apply RYGate. UniformDistribution.ryy(theta, qubit1, qubit2) Apply RYYGate. UniformDistribution.rz(phi, qubit) Apply RZGate. UniformDistribution.rzx(theta, qubit1, qubit2) Apply RZXGate. UniformDistribution.rzz(theta, qubit1, qubit2) Apply RZZGate. Apply SGate. Apply SdgGate. Returns total number of gate operations in circuit. UniformDistribution.snapshot(label[, …]) Take a statevector snapshot of the internal simulator representation. Take a density matrix snapshot of simulator state. Take a snapshot of expectation value of an Operator. Take a probability snapshot of the simulator state. Take a stabilizer snapshot of the simulator state. Take a statevector snapshot of the simulator state. UniformDistribution.squ(unitary_matrix, qubit) Decompose an arbitrary 2*2 unitary into three rotation gates. UniformDistribution.swap(qubit1, qubit2) Apply SwapGate. Apply SXGate. Apply SXdgGate. Apply TGate. Apply TdgGate. UniformDistribution.to_gate([parameter_map, …]) Create a Gate out of this circuit. Create an Instruction out of this circuit. UniformDistribution.toffoli(control_qubit1, …) Apply CCXGate. UniformDistribution.u(theta, phi, lam, qubit) Apply UGate. UniformDistribution.u1(theta, qubit) Apply U1Gate. UniformDistribution.u2(phi, lam, qubit) Apply U2Gate. UniformDistribution.u3(theta, phi, lam, qubit) Apply U3Gate. UniformDistribution.uc(gate_list, …[, …]) Attach a uniformly controlled gates (also called multiplexed gates) to a circuit. UniformDistribution.ucrx(angle_list, …) Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit. UniformDistribution.ucry(angle_list, …) Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit. UniformDistribution.ucrz(angle_list, …) Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit. UniformDistribution.unitary(obj, qubits[, label]) Apply unitary gate to q. Return number of qubits plus clbits in circuit. UniformDistribution.x(qubit[, label]) Apply XGate. Apply YGate. Apply ZGate. Return indexed operation. Return number of operations in circuit.