sf.apps.sample.modes_from_counts

modes_from_counts(s)[source]

Convert a list of counts to a list of modes where photons or clicks were observed.

Consider an \(M\)-mode sample \(s=\{s_{0},s_{1},\ldots,s_{M-1}\}\) of counts in each mode, i.e., so that mode \(i\) has \(s_{i}\) photons/clicks. If \(k = \sum_{ i=0}^{M-1} s_{i}\) is the total number of photons or clicks, this function returns a list of modes \(m=\{m_{1},m_{2},\ldots, m_{k}\}\) where photons or clicks were observed, i.e., so that photon/click \(i\) is in mode \(m_{i}\). Since there are typically fewer photons than modes, the latter form often gives a shorter representation.

Example usage:

>>> modes_from_counts([0, 1, 0, 1, 2, 0])
[1, 3, 4, 4]
Parameters

s (list[int]) – a sample of counts

Returns

a list of modes where photons or clicks were observed, sorted in non-decreasing order

Return type

list[int]