Boson Sampling Simulator#

class SamplingSimulator(d: int, config: Config | None = None, calculator: BaseCalculator | None = None)#

Performs photonic simulations using Fock representation with pure states.

The simulation (when executed) results in an instance of SamplingState.

Example usage:

import numpy as np
import piquasso as pq

from scipy.stats import unitary_group

d = 5

U = unitary_group.rvs(d)

with pq.Program() as program:
    pq.Q() | pq.StateVector([1, 1, 1, 0, 0])

    pq.Q() | pq.Interferometer(U)

    pq.Q(all) | pq.ParticleNumberMeasurement()

simulator = pq.SamplingSimulator(d=5)
result = simulator.execute(program, shots=100)
Supported preparations:

StateVector.

Supported gates:

Interferometer, Beamsplitter, Phaseshifter, MachZehnder, Fourier, Interferometer.

Supported measurements:

ParticleNumberMeasurement.

Supported channels:

Loss.