expectation_value

SimulationResult.expectation_value(operator, shot='avg', t_idx='all', basis='product', frame='rotating', in_qubit_subspace=True)

Return the expectation values of a given operator or operators.

Parameters:
  • operator (Operator | ndarray | Array | str | List[Operator | ndarray | Array | str]) – Operator or input of Operator. Could be a list.

  • shot (str | int | List[int]) – Specify the shot by its index or indices, or use 'avg'.

  • t_idx (str | int | List[int]) – Specify the time by its index or indices, or use 'all'.

  • basis (str) – Specify the basis, must be either 'product' or 'eigen'.

  • frame (str) – Specify the frame, must be either 'lab' or 'rotating'.

  • in_qubit_subspace (bool) – Specify whether the operator defined in the qubit subspace.

Return type:

ndarray | Array | List[ndarray | Array]

Returns:

Expectation values for shots and time points. Array of shape (n_shots, n_times, n_operators).

Raises:

SimphonyError – If the initial state is undefined.

Note

If the operator is given as a Pauli string, in_qubit_subspace must be True.