Skip to content

Commit

Permalink
Update noisy_distribution.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineRestivo authored Aug 30, 2022
1 parent 622f4df commit d8474c0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/distributions/noisy_distribution.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
noisy_distribution(;input::Input, reflectivity::Real, interf::Interferometer, exact=true, approx=true, samp=true)
noisy_distribution(;input::Input, loss::Real, interf::Interferometer, exact=true, approx=true, samp=true; error=1e-4, failure_probability=1e-4)
Compute the exact and/or approximated and/or sampled probability distribution of
all possible output configurations of partially-distinguishable photons through a
Expand All @@ -13,11 +13,11 @@ returns an array containing the three distributions.
!!! note "Reference"
[https://arxiv.org/pdf/1809.01953.pdf](https://arxiv.org/pdf/1809.01953.pdf)
"""
function noisy_distribution(;input::Input, reflectivity::Real, interf::Interferometer, exact=true, approx=true, samp=true)
function noisy_distribution(;input::Input, loss::Real, interf::Interferometer, exact=true, approx=true, samp=true; error=1e-4, failure_probability=1e-4)

output = []
ϵ = 1e-4
δ = 1e-4
ϵ = error
δ = failure_probability

input_modes = input.r.state
number_photons = input.n
Expand All @@ -30,14 +30,14 @@ function noisy_distribution(;input::Input, reflectivity::Real, interf::Interfero
get_parametric_type(input)[1] == Bosonic ? distinguishability = 1.0 : distinguishability = 0.0
end

number_output_photons = trunc(Int, number_photons*reflectivity)
number_output_photons = trunc(Int, number_photons*loss)
input_occupancy_modes = fill_arrangement(input_modes)

if reflectivity == 1 ||distinguishability == 0
if loss == 1 ||distinguishability == 0
throw(ArgumentError("invalid input parameters"))
end

ki = (log*δ*(1-reflectivity*distinguishability^2)/2))/log(reflectivity*distinguishability^2)
ki = (log*δ*(1-loss*distinguishability^2)/2))/log(loss*distinguishability^2)
ki = 10^(trunc(Int, log(10, ki)))
ki < 10 ? k = number_photons : k = min(ki, number_photons)
kmax = k-1
Expand Down

0 comments on commit d8474c0

Please sign in to comment.