richard — Apr 7, 2014, 7:13 PM
## I use mathematician's notation: theta is the azimuthal angle, phi is the polar
## (aka zenith) angle; both measured in radians.
## Reference: https://en.wikipedia.org/wiki/Spherical_coordinates
## Since my measurement directions all lie in equatorial plane I just extract "theta"
AliceDirections <-
read.table("http://www.math.leidenuniv.nl/~gill/AliceDirections.txt")
names(AliceDirections) <- c("theta", "phi")
head(AliceDirections) ## N pairs theta, phi (N rows, 2 columns)
theta phi
1 0.4558512 1.0748
2 0.5828188 2.0602
3 -0.6764309 0.9770
4 0.0008851 2.4905
5 0.5155671 1.2942
6 -0.1007671 0.7155
NAlice <- nrow(AliceDirections)
NAlice
[1] 100
AliceTheta <- AliceDirections$theta # Alice's azimuthal angles
head(AliceTheta)
[1] 0.4558512 0.5828188 -0.6764309 0.0008851 0.5155671 -0.1007671
BobDirections <-
read.table("http://www.math.leidenuniv.nl/~gill/BobDirections.txt")
names(BobDirections) <- c("theta", "phi")
head(BobDirections)
theta phi
1 1.4594 2.3205
2 0.5882 2.4816
3 -1.0540 0.8944
4 -0.2971 1.0470
5 1.2251 1.8913
6 -1.1389 2.3236
NBob <- nrow(BobDirections)
NBob
[1] 100
if (NAlice != NBob) print("Error: particle numbers don't match") else
print("Go ahead!")
[1] "Go ahead!"
BobTheta <- BobDirections$theta # Bob's azimuthal angles
head(BobTheta)
[1] 1.4594 0.5882 -1.0540 -0.2971 1.2251 -1.1389
## First pair of measurement directions
Alpha <- 0 * pi / 180
Beta <- 45 * pi / 180
A <- sign(cos(AliceTheta - Alpha))
B <- - sign(cos(BobTheta - Beta))
E11 <- mean(A * B)
## Second pair of measurement directions
Alpha <- 0 * pi / 180
Beta <- 135 * pi / 180
A <- sign(cos(AliceTheta - Alpha))
B <- - sign(cos(BobTheta - Beta))
E12 <- mean(A * B)
## Third pair of measurement directions
Alpha <- 90 * pi / 180
Beta <- 45 * pi / 180
A <- sign(cos(AliceTheta - Alpha))
B <- - sign(cos(BobTheta - Beta))
E21 <- mean(A * B)
## Fourth pair of measurement directions
Alpha <- 90 * pi / 180
Beta <- 135 * pi / 180
A <- sign(cos(AliceTheta - Alpha))
B <- - sign(cos(BobTheta - Beta))
E22 <- mean(A * B)
CHSH <- E12 - E11 - E21 - E22
CHSH
[1] 1.2
if (CHSH > 2.4) print("Congratulations, Joy") else
print("Congratulations, Richard")
[1] "Congratulations, Richard"
## Another experiment
AliceTheta <- runif(1000, 0, 360) * pi / 180
BobTheta <- - AliceTheta
Delta <- seq(from = 0, to = 360, by = 10) * pi / 180
Correlation <- numeric(length(Delta))
A <- sign(cos(AliceTheta))
i <- 0
for (delta in Delta) {
i <- i+1
B <- - sign(cos(BobTheta - delta))
Correlation[i] <- mean(A * B)
}
plot(Correlation)