symop.polynomial.kernels.measurements.number.observe

Observation kernels for polynomial number measurement.

This module implements non-destructive number measurement for polynomial ket and density states.

Unlike detection (sampling), observation evaluates the full probability distribution over measurement outcomes without collapsing the state. The result is returned as an ObservationResult.

Both standard number measurement and joint per-port number measurement are supported. The behavior is selected via action.resolution.grouping.

Notes

For ket states, probabilities are computed from squared norms of projected states. For density states, probabilities are obtained from traces of the corresponding projected density operators.

When joint per-port grouping is used, no scalar expectation value is returned, since the outcome space is multi-dimensional.

Functions

observe_number_detector_poly_density(*, ...)

Resolve number-observation statistics for a density state.

observe_number_detector_poly_ket(*, state, ...)

Resolve number-observation statistics for a ket state.

observe_number_detector_poly_density(*, state: DensityPolyState, action: ObserveAction, ctx: ApplyContext | None = None) ObservationResult

Resolve number-observation statistics for a density state.

Parameters:
  • state (DensityPolyState) – Polynomial density-state wrapper to be evaluated.

  • action (ObserveAction) – Semantic observe action defining the measurement target and resolution.

  • ctx (ApplyContext | None) – Optional apply context. Not used by this kernel.

Returns:

Observation result containing the probability distribution over number outcomes and, when applicable, the expectation value.

Return type:

ObservationResult

Notes

If action.resolution.grouping is MeasurementGrouppingEnum.JOINT_PORTS, joint per-port number statistics are resolved and returned. In this case, the expectation value is set to None.

Otherwise, standard number statistics are computed, and the expectation value is given by

\[\mathbb{E}[N] = \sum_n n\,p(n).\]

For density states, probabilities are computed from traces of projected density operators,

\[p(n) = \mathrm{Tr}(\Pi_n \rho \Pi_n).\]

The state is not modified by this operation.

observe_number_detector_poly_ket(*, state: KetPolyState, action: ObserveAction, ctx: ApplyContext | None = None) ObservationResult

Resolve number-observation statistics for a ket state.

Parameters:
  • state (KetPolyState) – Polynomial ket-state wrapper to be evaluated.

  • action (ObserveAction) – Semantic observe action defining the measurement target and resolution.

  • ctx (ApplyContext | None) – Optional apply context. Not used by this kernel.

Returns:

Observation result containing the probability distribution over number outcomes and, when applicable, the expectation value.

Return type:

ObservationResult

Notes

If action.resolution.grouping is MeasurementGrouppingEnum.JOINT_PORTS, joint per-port number statistics are resolved and returned. In this case, the expectation value is set to None.

Otherwise, standard number statistics are computed, and the expectation value is given by

\[\mathbb{E}[N] = \sum_n n\,p(n).\]

The state is not modified by this operation.