I agree with the sibling comment by eigenket:

> Everything up to the [spoiler ahead] in this comment is (as far as I can tell) exactly how things work in standard formulations of Bell's inequality. There's nothing weird or crackpot there.

Moreover, to clarify, it's not necessary that the hidden variables can be measurable or that you can set them. So if a system like the one you described must follow the Bell's Inequality if all the other hypothesis are true.

I read the code and it looks like an accurate implementation of the model proposed in the paper.

From the paper you liked:

> However, the expectation values E(X1X2), displayed
in (13) contain a factor 1/2, meaning that they do not violate CHSH inequality.

I agree with that part. The model should not violate the Bell's inequality or the equivalent version.

> The agreement with quantum predictions is obtained only after the “photon identification procedure”, which selects, from the raw data, final data samples.

The selection rule is the weird part. It's described in equations 7 and 8.

x := sign(1 + cos[2(a − φ)] − 2 · r1)

where r1 is a uniform random value between 0 and 1.

a is the angle of the polarizer

φ is the secret variable that is the angle of the photon. (QM says that this type of entangled photons have no a secret angle, this model assumes that each photon has a hidden variable that is the secret value φ.)

So far so good, this calculation gives the expected result if you assume that φ is chosen from a uniform distribution between 0° and 360°.

v := r2 |sin[2(a − φ)]|^d (Vmax − Vmin) − Vmax
selected := (v ≤ V)

where r2 is a uniform random value between 0 and 1.

With the numbers in your program

v := r2 |sin[2(a − φ)]|^2 (10 − 0) − 10
selected := (v ≤ -9.99)

that is equivalent to

selected := r2 |sin[2(a − φ)]|^2 ≤ -0.001

I've don't remember anything similar, and I can't imagine what it means experimentally.

Most of the times r2 is not tiny, so most of the times this means that the sine is tiny that means that the secret angle of the photon is almost aligned or almost orthogonal to the polarizer.

So this is a device that can measure the secret angle of the photon. This is not a real device, so it can't be proposed as an alternative explanation of the violation of the Bell's inequality.

You may be wondering why I claim it's not a real device.

If you have a detector of polarization, once you fix the angle 'a', you can't distinguish:

1) Unpolarized light, that is in particular the type of light used in a Bell's inequality test where the state is (|00> + |11>)/sqrt(2) or in other versions (|01> + |10>)/sqrt(2), where 0 is horizontal and v is vertical, or a uniform random values of φ in the model of the paper

2) Light polarized in 45° to the detector's angle, that is like a constant φ in both models.

In both cases, you detect 50% of the photons.

If you use the selection device of this paper,

1) with unpolarized light you will get selections when r2 is very small or when φ is almost paraller or orthogonal to the angle a.

2) with polarized light at 45° you will get selections when r2 is very small

So with polarized light at 45° the number of events will be much smaller than with not polarized light.

In particular if you have the source of not polarized light and the detector, adding a polarizer at 45° in the middle will reduce the number of events in the firs case to 1/4 and in the other to almost 0.