Here are the basic ingredients of the simulation, which should allow one to implement it in a different programming language.
LabVIEW is indeed a graphical programming language, and unfortunately will probably look cryptic to someone not familiar with it.
1. Random photon time stamp generation
To generate photon time stamps obeying the probability distribution of a T-periodic single-exponential decay with lifetime tau (L_tau,T(t) in the following), we use the rejection principle, according to which it is enough to generate random numbers {x_i} distributed uniformly in [0, F(T)], where F is the primitive of a comparison function f(t) such that f(t) >= L_tau,T(t).
These random numbers can be associated with time stamps t_i = F^-1(x_i), which are retained as valid only if L_tau,T(t_i) > f(t_i).
Initialization of a few parameters (alpha, beta, gamma and F(T)) is performed each time a different set of values (tau, T) is used. This takes place in the "False" case of the structure above, depicted in the snapshot below:
2. Main Simulation Loop
The rest of the simulation is rather simple. As indicated in the diagram's snapshot below, for each set of parameters (d: gate step, W: gate width, G: gate number and N: number of photons), which are themselves looped through to compute complete simulation curves, the following computation is repeated (inside loop, with a red dot below the N in the top-left corner) as many times (S: Simulation Number) as requested for each point:
- Compute N Random Time Stamps (as described above);
- Pick up a random gate for each time stamp, and accumulate signal in the gates in this random manner, obtaining a "decay" as a result (pink wire output of "Compute Decay from Photons";
- Compute a phasor from this decay;
- Calibrate the phasor with the provided calibration phasor, Z_c, and compute the corresponding phase lifetime (tau_phi);
- Repeat S times and compute the average phase lifetime (<tau>) and standard deviation (SDV);
- Repeat for the requested series of parameters (e.g. different W values) and output the corresponding plots (not shown).