expectation_value

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

Return the expectation values of a given operator or operators.

Parameters:
  • operator (Operator | ndarray | Array | str | List[Operator | ndarray | Array | str]) – Operator, square matrix, Pauli string, or list of these. Strings may include I, X, Y, Z (qubit subspace), x, y, z, 1, M symbols (full Hilbert space).

  • 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'.

  • source (str | None) – Explicit expectation-value source forwarded to plot_expectation_value().

  • in_qubit_subspace (bool) – If True the state is projected to the qubit subspace. Ignored when any operator string contains 1 or M.

  • source – Explicit expectation-value source. Must be 'state' or 'density_matrix' when both time_evol_state and time_evol_density_matrix are present.

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

X, Y and Z denote the Pauli operators in the qubit subspace. x, y and z denote the full-spin operators \(S_x\), \(S_y\) and \(S_z\). I denotes the qubit-subspace identity while 1 denotes the full-spin identity. M denotes the full-spin \(S_z^2\) operator (corresponding to the photoluminescence signal for the NV center).