# CSHS Inequality - and noise

1. Jun 10, 2014

### .Scott

I never heard of the CSHS Inequality until I read it in another thread.
I think an important part of that discussion is the more hits are ignored, the easier it is for local realistic theories to score over 2.00. So I just had to try.

For those familiar with C++, I offer this simulated experiment:
Code (Text):
#include "stdafx.h"
#define _CRT_RAND_S
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <atlstr.h>

using namespace System;

#define TRYCOUNT 1000

//
// Random number generators: range of 0.0 to 1.0.
double RNG()
{
unsigned int nRandom;
rand_s(&nRandom);
return ((double)nRandom) / UINT_MAX;
}

//
// We have a selection of 4 polarizer/splitters.
static double Splitters[4] = { 0.0, 45.0, 22.5, 67.5 };

//
// Here is the noiseless QM model.
void QMModel(double AngleA, double AngleB, int &ResultA, int &ResultB)
{
double Agree;

ResultA = ResultB = (RNG()<0.5) ? -1 : 1;
if(RNG()>Agree) ResultA = -ResultA;
}

//
// Here is a local model that includes built-in misses.
// Result will be:
//   +1: Detected by the "+" detector.
//   -1: Detected by the "-" detector.
//    0: Not detected!
//
void LocalModel(double Hidden, double Angle, int &Result)
{
double Split;

Result = 1;
if(Split<0.0) {
Split = -Split;
Result = -1;
}
if(RNG()>Split) Result = 0;
}

//
void ExpectedValues
(int nTries, int nAngleA, int nAngleB, double &EQM, double &ELocal)
{
double AngleA, AngleB, Hidden;
int  nTry, ResultA, ResultB, nMeasured, EVNumerator;
CStringA Report;

nQMAgree = nLocalAgree = nQMDisagree = nLocalDisagree = 0;
AngleA = Splitters[nAngleA];
AngleB = Splitters[nAngleB];

for(nTry=0;nTry<nTries;nTry++) {
QMModel(AngleA,AngleB,ResultA,ResultB);

else if((ResultA>0)&&(ResultB>0)) nQMAgree++;
else if((ResultA<0)&&(ResultB<0)) nQMAgree++;
else nQMDisagree++;

//
// In the local model, a hidden value is carried by both particles.
Hidden = 360.0 * RNG();
LocalModel(Hidden,AngleA,ResultA);
LocalModel(Hidden,AngleB,ResultB);

else if((ResultA>0)&&(ResultB>0)) nLocalAgree++;
else if((ResultA<0)&&(ResultB<0)) nLocalAgree++;
else nLocalDisagree++;
}
//
Report.Format(
"\nResults with splitters: A=%1.1f°, B%1.1f°\n",
AngleA, AngleB
);
puts(Report);
//
// Report noiseless QM results.
nMeasured = nQMAgree + nQMDisagree;
EVNumerator = nQMAgree - nQMDisagree;
EQM = ((double)EVNumerator)/nMeasured;
Report.Format(
"  Noiseless QM Model:\n"
"    Agree:    %d/%d (%.2f%%)\n"
"    Disagree: %d/%d (%.2f%%)\n"
"    Expected: %d/%d (%.2f%%)\n",
nQMAgree, nMeasured, (nQMAgree*100.0)/nMeasured,
nQMDisagree, nMeasured, (nQMDisagree*100.0)/nMeasured,
EVNumerator, nMeasured, 100.0*EQM
);
puts(Report);
//
// Report local results.
nMeasured = nLocalAgree + nLocalDisagree;
EVNumerator = nLocalAgree - nLocalDisagree;
ELocal = ((double)EVNumerator)/nMeasured;
Report.Format(
"  Local Model:\n"
"    Agree:    %d/%d (%.2f%%)\n"
"    Disagree: %d/%d (%.2f%%)\n"
"    Expected: %d/%d (%.2f%%)\n",
nLocalAgree, nMeasured, (nLocalAgree*100.0)/nMeasured,
nLocalDisagree, nMeasured, (nLocalDisagree*100.0)/nMeasured,
EVNumerator, nMeasured, 100.0*ELocal
);
puts(Report);
}

//
int main()
{
double dQM_CSHS, dLl_CSHS;
double EQMAB, EQMAb, EQMaB, EQMab, ELlAB, ELlAb, ELlaB, ELlab;
CStringA Report;

//
//  Perform the experiment four times with the polarizing splitters
// at different setting combinations.
ExpectedValues(TRYCOUNT, 0, 2, EQMAB, ELlAB);
ExpectedValues(TRYCOUNT, 0, 3, EQMAb, ELlAb);
ExpectedValues(TRYCOUNT, 1, 2, EQMaB, ELlaB);
ExpectedValues(TRYCOUNT, 1, 3, EQMab, ELlab);
//
// Tally and report the results.
dQM_CSHS     = EQMAB - EQMAb + EQMaB + EQMab;
dLl_CSHS     = ELlAB - ELlAb + ELlaB + ELlab;
Report.Format(
"\nQM CSHS = %.4f\nLocal CSHS = %.4f\n",
dQM_CSHS,dLl_CSHS
);
puts(Report);
_getch();
return 0;
}
When I ran this, I got these results:
Code (Text):

Results with splitters: A=0.0°, B22.5°

Noiseless QM Model:
Agree:    833/1000 (83.30%)
Disagree: 167/1000 (16.70%)
Expected: 666/1000 (66.60%)

Local Model:
Agree:    455/458 (99.34%)
Disagree: 3/458 (0.66%)
Expected: 452/458 (98.69%)

Results with splitters: A=0.0°, B67.5°

Noiseless QM Model:
Agree:    138/1000 (13.80%)
Disagree: 862/1000 (86.20%)
Expected: -724/1000 (-72.40%)

Local Model:
Agree:    247/324 (76.23%)
Disagree: 77/324 (23.77%)
Expected: 170/324 (52.47%)

Results with splitters: A=45.0°, B22.5°

Noiseless QM Model:
Agree:    855/1000 (85.50%)
Disagree: 145/1000 (14.50%)
Expected: 710/1000 (71.00%)

Local Model:
Agree:    457/458 (99.78%)
Disagree: 1/458 (0.22%)
Expected: 456/458 (99.56%)

Results with splitters: A=45.0°, B67.5°

Noiseless QM Model:
Agree:    853/1000 (85.30%)
Disagree: 147/1000 (14.70%)
Expected: 706/1000 (70.60%)

Local Model:
Agree:    446/452 (98.67%)
Disagree: 6/452 (1.33%)
Expected: 440/452 (97.35%)

QM CSHS = 2.8060
Local CSHS = 2.4313

It is claimed (wikipedia) that the angles I picked, 0, 45, 22.5, and 67.5, produce the greatest deviation from the classical results. Is this why I got such as high value for the QM model (2.8) or did I mess something up?

The 2.4313 value is slightly lucky. When I set "TRIES" to 100000, I got value closer to 2.40. In any case, assuming the code is good, it demonstrates that an experimental value of 2.4 might be discounted if the number of discards is as much as the number of hits.

2. Jun 10, 2014

### .Scott

Having looked at this some more, that 2.82 value is looking OK. I noticed that, although DrChinese gave a range 2.25 to 2.40, he also said that 2.82 was the maximum.

The article he cited ( http://arxiv.org/pdf/quant-ph/0205171v1.pdf ) gives a value of 2.307, but they are working with more than four angles. I'm looking at the table on page 7 of that article.

I need to read more to figure out exactly how they got that number. Actually, if anyone can give me a hint as to how I can generate that 2.307 value, I'd appreciate it.

I also noticed that my local model is actually capable of generating values in excess of 3.5 using 0,90,45,135. I need to add code to that local version to report the number of discarded readings that never showed up at any detector - since in a real-life experiment, those would be discards that would not even be recognized as such.