Did I Mess Up My CHSH Inequality Simulation?

  • Thread starter Thread starter .Scott
  • Start date Start date
  • Tags Tags
    Inequality Noise
Click For Summary
The discussion centers on the CHSH inequality, which is crucial for Bell tests, typically using a threshold of 2.00 for classical theories and a quantum maximum of about 2.82. The participant shares a C++ simulation that compares results from a quantum model and a local realistic model, highlighting the importance of match percentages in evaluating results. They observe that their quantum model yielded a value of 2.8060, which is close to the theoretical maximum, while the local model produced a value of 2.4313. The conversation also touches on the implications of discarded hits in experiments and the need for further exploration to understand discrepancies in reported values from different studies.
.Scott
Science Advisor
Homework Helper
Messages
3,864
Reaction score
1,924
I never heard of the CSHS Inequality until I read it in another thread.
DrChinese said:
As a practical matter: most Bell tests do not use the 25% vs 33% standard for ruling out classical theories. Instead they use what is called the CHSH inequality. You can read about it in the references. It has an upper bound of 2.00 for classical (local realistic) theories, so predicts something below 2.00. That maps to the 33%. The quantum theoretical max is about 2.82. Bell tests usually give a value between 2.25 and 2.40.
The other interesting item was this:
DrChinese said:
I usually talk about match % because it is easier to discuss and relate to the cos^2 formula. Then the formula is:
Matches/(Matches+NonMatches) where hits that cannot be paired are ignored. In real experiments, unpaired hits are usually noted and discussed.
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:
#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
#define RADIANS 0.01745329251994329576923690768489

//
// 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;
  Agree = pow( (cos(RADIANS*(AngleA-AngleB))), 2);
  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;
  Split = cos(RADIANS*(Angle-Hidden));
  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)
{
  int  nQMDiscard, nQMAgree, nQMDisagree;
  int  nLocalDiscard, nLocalAgree, nLocalDisagree;
  double AngleA, AngleB, Hidden;
  int  nTry, ResultA, ResultB, nMeasured, EVNumerator;
  CStringA Report;

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

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

    if((ResultA==0)||(ResultB==0)) nQMDiscard++;
    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);

    if((ResultA==0)||(ResultB==0)) nLocalDiscard++;
    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"
    "    Discard:  %d/%d (%.2f%%)\n"
    "    Agree:    %d/%d (%.2f%%)\n"
    "    Disagree: %d/%d (%.2f%%)\n"
    "    Expected: %d/%d (%.2f%%)\n",
    nQMDiscard, nTries, (nQMDiscard*100.0)/nTries,
    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"
    "    Discard:  %d/%d (%.2f%%)\n"
    "    Agree:    %d/%d (%.2f%%)\n"
    "    Disagree: %d/%d (%.2f%%)\n"
    "    Expected: %d/%d (%.2f%%)\n",
    nLocalDiscard, nTries, (nLocalDiscard*100.0)/nTries,
    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:
Results with splitters: A=0.0°, B22.5°

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

  Local Model:
    Discard:  542/1000 (54.20%)
    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:
    Discard:  0/1000 (0.00%)
    Agree:    138/1000 (13.80%)
    Disagree: 862/1000 (86.20%)
    Expected: -724/1000 (-72.40%)

  Local Model:
    Discard:  676/1000 (67.60%)
    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:
    Discard:  0/1000 (0.00%)
    Agree:    855/1000 (85.50%)
    Disagree: 145/1000 (14.50%)
    Expected: 710/1000 (71.00%)

  Local Model:
    Discard:  542/1000 (54.20%)
    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:
    Discard:  0/1000 (0.00%)
    Agree:    853/1000 (85.30%)
    Disagree: 147/1000 (14.70%)
    Expected: 706/1000 (70.60%)

  Local Model:
    Discard:  548/1000 (54.80%)
    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.
 
Physics news on Phys.org
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.
 
Time reversal invariant Hamiltonians must satisfy ##[H,\Theta]=0## where ##\Theta## is time reversal operator. However, in some texts (for example see Many-body Quantum Theory in Condensed Matter Physics an introduction, HENRIK BRUUS and KARSTEN FLENSBERG, Corrected version: 14 January 2016, section 7.1.4) the time reversal invariant condition is introduced as ##H=H^*##. How these two conditions are identical?

Similar threads

Replies
24
Views
24K