R accCoin
From MariachiWiki
Jason Immerman wrote a script to mimic a setup of two detectors with user supplied rates r1 and r2 and a user supplied window for which coincidences are counted, w, that will return the accidental coincidence rate for the setup. To source the script (here) one must set R's working directory as the folder containing accCoin.R and then enter into the R console:
>source(accCoin.R)
To run the script call the method driverCoin(r1,r2,w). The rate should match that (within the given accuracy of 1%) produced by the equation r=2*r1*r2*w. The script will output to the R terminal the time interval that elapsed in the mock setup until the accuracy was obtained, the number of accidental coincidences in this time period, the accuracy of the accidental coincidence rate and finally the rate itself:
The time interval, in seconds, is [1] 892.1978 The number of coincidences is [1] 10000 The program ran with an accuracy of [1] 0.01 The rate of accidental coincidences, in Hz, is [1] 11.20828
The script works by initializing both detectors to a time of 0 and using a random number generator to iterate both detectors forward to an initial misfire event, based on the equation (1/r)*log(x) where 0<x<1. Following this the lower time is iterated forward by a the same random interval. Each iteration, if the two times fall within w then a coincidence is recorded. The program returns when the accuracy of 1% is reached, based on accuracy = 1/sqrt(N), where N is the number of coincidences.
