FrediFizzx wrote:@gill1109 Every thing I do is already defined in the paper. Reed's code is not the same as what I do. If you follow that, it will be a strawman. A non-local one. It would be easier to just do the non-local sim I did for a non-local simulation in R. Simple "or" functions. There is no particular "permutations". If you have a question about the code, just ask it. Most of the code is pretty self explanatory. So, if you tell me what you don't understand then I will annotate that part.
John Reed verified that his code produced identical results to yours. I have further simplified his code and rewritten it in R.
- Code: Select all
M <- 100000
set.seed(1234)
aBits <- sample(c(0, 1), size = M, replace = TRUE)
bBits <- sample(c(0, 1), size = M, replace = TRUE)
aRadians <- aBits * pi / 2
bRadians <- bBits * pi / 2 + pi / 4
set.seed(5678)
R <- 0.25 * cos(runif(M, 0, pi))^2 # Fodje's M hidden variables rho
S <- runif(M, 0, 2*pi) # Angles of M spin vectors (radians)
C <- abs(cos(aRadians - S)) < R # TRUE is "fail", FALSE is "good"
A <- ifelse(C, -sign(sin(aRadians - S)), -sign(cos(aRadians - S)))
AA <- -sign(sin(aRadians - S))
D <- abs(cos(bRadians - S)) < R # TRUE is "fail", FALSE is "good"
B <- ifelse(D, +sign(sin(bRadians - S)), +sign(cos(bRadians - S)))
BB <- +sign(sin(bRadians - S))
A <- ifelse(D & !(A == AA), -A, A)
B <- ifelse(C & !(B == BB), -B, B)
mean((A*B)[aBits == 0 & bBits == 0])
mean((A*B)[aBits == 0 & bBits == 1])
mean((A*B)[aBits == 1 & bBits == 0])
mean((A*B)[aBits == 1 & bBits == 1])
- mean((A*B)[aBits == 0 & bBits == 0]) + mean((A*B)[aBits == 0 & bBits == 1]) -
mean((A*B)[aBits == 1 & bBits == 0]) - mean((A*B)[aBits == 1 & bBits == 1])
The result was S = 2.63625
I noticed that Fred's code used the function "Sort" which one would expect would produce a permutation, but John Reeds didn't. You can see the nonlocality in the lines where the sign of the outcomes A and B are switched depending in part on information from the other wing of the experiment - Fred's C1 and C2 which I now called C and D.
I should imagine that you would get better results using Pearl's model rather than Michel Fodje's. It should now be easy to compute analytically what is going on, and also to compute how many non-local sign switches are performed.
If anyone disagrees I suggest they do their own conversion of Fred's Mathematica code to R or Python, and while they're at it, remove superfluous objects leading to superfluous copyings and renamings which only make the code harder to read.
Note: the R function ifelse(test, x, y) evaluates "test" and returns "x" or "y" depending on whether "test" delivers TRUE or FALSE. It works on vectors elementwise, delivering a vector of results of the same length as test, x and y. Notice that I originally chose binary settings completely at random, later converting them to the standard angles measured in radians. I chose the spin vector uniformly at random on the circle, rather than choosing it at random as a whole number of degrees.