Quantum entanglement

No.13691477 ViewReplyOriginalReport
Scientifically, how do we explain the fact that I can simulate a Bell's inequality violation using a simple model of a photon and polarizer?

from collections import defaultdict
from random import seed, choice, uniform
from math import sin, cos, pi
import numpy as np
import matplotlib.pyplot as plt

class Photon:
def __init__(self):
self.angle = choice(range(360))

class Polarizer:
def receive(self, photon):
threshold = sin((photon.angle/2)*(pi/180))**2
return 1 if uniform(0, 1) < threshold else 0

def run_trial(angle):
polarizer = Polarizer()
photon = Photon()
return polarizer.receive(photon), photon.angle

def test_bell(count):
test = count[45] > count[22] + count[23]
relation = ">" if test else "<"
print("%f %s 2 * %f = %f" % (count[45], relation, count[22], count[22] + count[23]))
return test

def run_experiment():
seed()
count = defaultdict(int)
for angle in range(360):
for _ in range(NUM_TRIALS):
r, theta = run_trial(angle)
count[theta] += r

for angle in range(360):
count[angle] /= float(NUM_TRIALS)

print("Bell's inequality violated?", test_bell(count))
return count

def plot_results(count):
fig, ax = plt.subplots()

plt.title("Experimental Results")
plt.xlabel("Angle (degrees)")
plt.ylabel("Probability")

x = np.arange(0, 360, 1)
y = count.values()

ax.plot(y, color='black', label='Polarizer')
plt.ylim([0, 1.05])
plt.yticks(map(lambda x: float(x)/10, range(11)))
plt.legend()
plt.show()

if __name__=='__main__':
NUM_TRIALS = 10000
plot_results(run_experiment())