feature_vector_events(graph, event_photon_numbers, max_count_per_mode=2, n_mean=5, samples=None, loss=0.0)[source]

Calculates feature vector of event probabilities for the input graph.

These probabilities can be either exact or estimated using Monte Carlo estimation. The argument samples is set to None to get exact feature vectors by default. To use Monte Carlo estimation, samples can be set to the number of samples desired to be used in the estimation.


Computing exact probabilities for a large number of events, especially for events with high total photon numbers, can be quite time-consuming. For example, calculating the exact probabilities of observing 8 total photons in a 25 mode graph can take on the order of a few minutes. Monte Carlo estimation, although less precise, can be much quicker.

Example usage:

>>> graph = nx.erdos_renyi_graph(8, p=0.7, seed=0)
>>> feature_vector_events(graph, [2, 3, 4, 6], 1)
[0.21962528885336693, 0.0, 0.06542564576021911, 0.008278357709166432]
>>> feature_vector_events(graph, [2, 3, 4, 6], 1, samples = 1000)
[0.21559451884617312, 0.0, 0.06445223981110329, 0.008332933548878733]
  • graph (nx.Graph) – input graph

  • event_photon_numbers (list[int]) – a list of events described by their total photon number

  • max_count_per_mode (int) – maximum number of photons per mode for all events

  • n_mean (float) – total mean photon number of the GBS device

  • samples (int) – optional number of samples used in the Monte Carlo estimation. Defaults to exact calculation if samples is unspecified.

  • loss (float) – fraction of photons lost in GBS


a feature vector of event probabilities in the same order as event_photon_numbers

Return type