paddle_quantum.shadow

Shadow sample module.

paddle_quantum.shadow.shadow_sample(state, num_qubits, sample_shots, mode, hamiltonian=None, method='CS')

Measure a given quantum state with random Pauli operators and return the measurement results.

Parameters:
  • state (State) – Input quantum state, which is either a state vector or a density matrix.

  • num_qubits (int) – The number of qubits.

  • sample_shots (int) – The number of random samples.

  • mode (Backend) – Representation form of the input quantum state.

  • hamiltonian (Hamiltonian | None) – A Hamiltonian object representing the observable to be measured. Defaults to None.

  • method (str) – Method for sampling random Pauli operators, which should be one of 'CS', 'LBCS', and 'APS'. Defaults to 'CS'.

Raises:
  • ValueError – Hamiltonian has a bad form

  • NotImplementedError – The backend of state should be StateVector or DensityMatrix

Returns:

Randomly chosen Pauli operators and their corresponding measurement result in a list of shape (sample_shots, 2).

Return type:

list