mindquantum.core.gates.PauliChannel

View Source On Gitee
class mindquantum.core.gates.PauliChannel(px: float, py: float, pz: float, **kwargs)[source]

A pauli channel.

Pauli channel express error that randomly applies an additional \(X\), \(Y\) or \(Z\) gate on qubits with different probabilities \(P_x\), \(P_y\) and \(P_z\), or do noting (applies \(I\) gate) with probability \(1-P_x-P_y-P_z\).

Pauli channel applies noise as:

\[\epsilon(\rho) = (1 - P_x - P_y - P_z)\rho + P_x X \rho X + P_y Y \rho Y + P_z Z \rho Z\]

where \(\rho\) is quantum state as density matrix type; \(P_x\), \(P_y\) and \(P_z\) is the probability of applying an additional \(X\), \(Y\) and \(Z\) gate.

Parameters
  • px (int, float) – probability of applying X gate.

  • py (int, float) – probability of applying Y gate.

  • pz (int, float) – probability of applying Z gate.

Examples

>>> from mindquantum.core.gates import PauliChannel
>>> from mindquantum.core.circuit import Circuit
>>> circ = Circuit()
>>> circ += PauliChannel(0.8, 0.1, 0.1).on(0)
>>> circ.measure_all()
>>> print(circ)
      ╔══════════════════════════════╗ ┍━━━━━━┑
q0: ──╢ PC(px=4/5, py=1/10, pz=1/10) ╟─┤ M q0 ├───
      ╚══════════════════════════════╝ ┕━━━━━━┙
>>> from mindquantum.simulator import Simulator
>>> sim = Simulator('mqvector', 1)
>>> sim.sampling(circ, shots=1000, seed=42)
shots: 1000
Keys: q0│0.00     0.2         0.4         0.6         0.8         1.0
────────┼───────────┴───────────┴───────────┴───────────┴───────────┴
       0│▒▒▒▒▒▒▒

       1│▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓

{'0': 101, '1': 899}
define_projectq_gate()[source]

Define the corresponded projectq gate.

get_cpp_obj()[source]

Get underlying C++ object.

matrix()[source]

Kraus operator of the quantum channel.

Returns

list, contains all Kraus operators of this quantum channel.