sf.apps.similarity.feature_vector_orbits¶
-
feature_vector_orbits
(graph, list_of_orbits, n_mean=5, samples=None, loss=0.0)[source]¶ Calculates feature vector of orbit probabilities for the input graph.
These probabilities can be either exact or estimated using Monte Carlo methods. The argument
samples
is set toNone
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.Warning
Computing exact probabilities for a large number of orbits, especially for orbits 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_orbits(graph, [[1,1], [2,1,1], [1,1,1,1], [2, 2]]) [0.21962528885336693, 0.06276606666427528, 0.06542564576021911, 0.009042568926209148]
>>> feature_vector_orbits(graph, [[1,1], [2,1,1], [1,1,1,1], [2, 2]], samples = 1000) [0.21559451884617312, 0.06326819519758922, 0.06381925998626868, 0.008802142975935753]
- Parameters
graph (nx.Graph) – input graph
list_of_orbits (list[list[int]]) – a list of orbits
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
- Returns
a feature vector of orbit probabilities in the same order as
list_of_orbits
- Return type
list[float]