Hi Peter,
Thanks for your kind comments. It seems that many others, myself included, have exploited the detection loophole to violate Bell's inequality, but I have seen only one that converges to the sinusoidal correlation expected from QM. Richard Gill's analysis of Philip Pearle's work on quaternions resulted in this procedure, which converges nicely. I also posted the procedure with Declan's essay.
The method requires three(!) random numbers R1,R2,R3 generated uniformly over the interval 0-1 for each trial. Gill stores a large set of transformed random numbers, z,x,s, to be reused in trials for any combination of settings by Alice and Bob.
The first two random numbers are transformed to cover a spherical shell, and then projected onto a plane running through the center, forming a disc. Points on the plane are taken as 2d vectors (z,x), so the distribution of their magnitude is biased towards the edge of the disc, where it is most dense.
The third random number sets the threshold, s, for detection, with another carefully crafted distribution.
z = 2 R1 - 1
x = sqrt(1 - z^2) cos(2 pi R2)
s = [ 2 / sqrt(3 R3 1) ] - 1
A unit vector (az,ax) in the z-x plane sets Alice's angle, with (bz,bx) for Bob. Projections are calculated as follows
pa = (z,x) . (az,ax) = z az x ax
pb = (z,x) . (bz,bx) = z bz x bx
A detection occurs when the absolute value of both pa and pb is greater than s. The correlation for a detected event is given by the product of the signs of their projections
C = sign(pa) sign(pb)
The average correlation for this Gill-Pearle method converges to the cosine expectation as the number of trials is increased.
I tried implementing Declan Traill's algorithm in C without success so far. The procedures are similar, and the javascript code for noise generation and decision-making is easy to follow, but I have made some error in calculation, and will have to spend more time looking for it, or start over.
Cheers,
Colin