bosonSampler {BosonSampling} | R Documentation |
The function implements the Boson Sampling algorithm defined in Clifford and Clifford (2017) https://arxiv.org/abs/1706.01260
bosonSampler(A, sampleSize, perm = FALSE)
A |
the first |
sampleSize |
the number of independent sample values required for given |
perm |
TRUE if the permanents and pmfs of each sample value are required |
Let the matrix A
be the first n
columns of an (m x m)
random unitary matrix, then
X <- bosonSampler(A, sampleSize = N, perm = TRUE)
provides X$values
, X$perms
and X$pmfs
,
The component X$values
is an (n x N)
matrix with columns that are
independent sample values from the Boson Sampling distribution.
Each sample value is a vector of n
integer-valued output modes in random order. The elements of the vector can be sorted in
increasing order to provide a multiset representation of the sample value.
The outputs X$perms
and X$pmfs
are
vectors of the permanents and probability mass functions (pmfs) associated with the sample values.
The permanent associated with a sample value v = (v_1,...,v_n)
is the permanent of an (n x n)
matrix constructed with rows
v_1,...,v_n
of A
. Note the constructed matrix, M
, may have repeated rows since v_1,...,v_n
are not necessarily distinct.
The pmf is calculated as Mod(pM)^2/prod(factorial(tabulate(c))
where pM
is the permanent of M
.
X = bosonSampler(A, sampleSize = N, perm = TRUE)
provides X$values
, X$perms
and X$pmfs
. See Details.
Clifford, P. and Clifford, R. (2017) The Classical Complexity of Boson Sampling, https://arxiv.org/abs/1706.01260
set.seed(7)
n <- 20 # number of photons
m <- 200 # number of output modes
A <- randomUnitary(m)[,1:n]
# sample of output vectors
valueList <- bosonSampler(A, sampleSize = 10)$values
valueList
# sample of output multisets
apply(valueList,1, sort)
#
set.seed(7)
n <- 12 # number of photons
m <- 30 # number of output modes
A <- randomUnitary(m)[,1:n]
# sample of output vectors
valueList = bosonSampler(A, sampleSize = 1000)$values
# Compare frequency of output modes at different
# positions in the output vectors
matplot(1:m,apply(valueList,1,tabulate), pch =20, t = "p",
xlab = "output modes", ylab = "frequency")