Passive State¶
- class PassiveState(d: int, connector: BaseConnector, config: Config | None = None)¶
A state dedicated for Boson Sampling (or related) simulations.
When using
PassiveSimulator, the simulation results will contain an instance of this class, containing the input occupation numbers and the interferometer to be applied. Moreover, postselections and losses can also be specified in this state.Consider the input state
\[\ket{\psi} = \sum_i c_i \ket{\mathbf{n}^{(i)}},\]where \(\ket{\mathbf{n}^{(i)}}\) are Fock states defined on \(d\) modes, and \(c_i\) are the corresponding coefficients. Consider now a possibly lossy passive linear circuit \(\mathcal{C}\) modeled by the quantum channel \(\Lambda_{\mathcal{C}}\), resulting in the output state
\[\rho_{\text{out}} = \Lambda_{\mathcal{C}}(\ketbra{\psi}{\psi}).\]Optionally, certain modes can be postselected to specific photon counts \(\mathbf{m}\), resulting in the final (possibly unnormalized) state
\[\rho_{\text{postselected}} = \mathrm{Tr}_{\text{postselected modes}} \left[ (I \otimes \ketbra{\mathbf{m}}{\mathbf{m}}) \, \rho_{\text{out}} \right],\]where \(I \otimes \ketbra{\mathbf{m}}{\mathbf{m}}\) is the projector corresponding to the postselection.
Losses can be specified by
Loss, and post- selections byPostSelectPhotons.Example usage:
>>> import piquasso as pq >>> >>> from scipy.stats import unitary_group >>> >>> d = 7 >>> >>> interferometer_matrix = unitary_group.rvs(d) >>> >>> with pq.Program() as program: >>> pq.Q(all) | pq.StateVector([1, 1, 1, 0, 0, 0, 0]) >>> pq.Q(all) | pq.Interferometer(interferometer_matrix) >>> pq.Q(all) | pq.ParticleNumberMeasurement() >>> >>> simulator = pq.PassiveSimulator(d=d) >>> >>> result = simulator.execute(program, shots=3) >>> >>> result.samples [(0, 0, 0, 0, 2, 1, 0), (3, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 2, 1)]
- Parameters:
d (int) – The number of modes.
connector (BaseConnector) – Instance containing calculation functions.
config (Config) – Instance containing constants for the simulation.
- property is_indistinguishable: bool¶
Returns True if the state consists of indistinguishable particles, otherwise False.
- property is_partially_distinguishable: bool¶
Returns True if the state consists of partially distinguishable particles, otherwise False.
- property is_uniformly_partially_distinguishable: bool¶
Returns True if the state consists of uniformly partially distinguishable particles, otherwise False.
- property is_nonuniformly_partially_distinguishable: bool¶
Returns True if the state consists of non-uniformly partially distinguishable particles, otherwise False.
- validate() None¶
Validates the current state.
- Raises:
InvalidState – If the interferometer matrix is non-unitary, or the input state is invalid.
- property d¶
The number of modes.
- property norm¶
The norm of the state.
- normalize() None¶
Normalizes the state.
- Raises:
InvalidState – If the norm of the state is 0.
- get_particle_detection_probability(occupation_number: ndarray) float¶
Returns the particle number detection probability using the occupation number specified as a parameter.
- property state_vector¶
The state vector representation of this state.
The state vector is calculated in the truncated Fock space, taking into account any postselections that may have been applied. Moreover, the ordering of the Fock basis is increasing with particle numbers, and in each particle number conserving subspace, anti-lexicographic ordering is used.
- Raises:
NotImplementedCalculation – If the state is lossy or partially distinguishable.
- to_pure_fock_state() piquasso._simulators.fock.pure.state.PureFockState¶
Converts this state to a pure Fock state.
- Returns:
The corresponding pure Fock state.
- Return type:
- get_marginal_fock_probabilities(modes: Tuple[int, ...]) Dict[Tuple[int, ...], float]¶
Returns the marginal probabilities of the state.
Note
If the state is postselected, the marginal probabilities are not normalized, and the sum of the marginal probabilities is equal to the probability of the postselection.