# sf.apps.sample.sample¶

sample(A, n_mean, n_samples=1, threshold=True, loss=0.0)[source]

Generate simulated samples from GBS encoded with a symmetric matrix $$A$$.

Example usage:

>>> g = nx.erdos_renyi_graph(5, 0.7)
>>> a = nx.to_numpy_array(g)
>>> sample(a, 3, 4)
[[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]

Parameters
• A (array) – the symmetric matrix to sample from

• n_mean (float) – mean photon number

• n_samples (int) – number of samples

• threshold (bool) – perform GBS with threshold detectors if True or photon-number resolving detectors if False

• loss (float) – fraction of generated photons that are lost while passing through device. Parameter should range from loss=0 (ideal noise-free GBS) to loss=1.

Returns

a list of samples from GBS with respect to the input symmetric matrix

Return type

list[list[int]]