Simulation of CHSH inequality experiment in Excel

  • #1
lostinmygarden
32
2
TL;DR Summary
I have tried to create a simulation of CHSH experiment in Excel. I am assuming photons have a set polarization after creation and the entangled pairs have the same polarization. I would like feedback on this.
I would like reviews of the CHSH inequality experiment simulation, that I have created in excel.

This is an open share, you can access anonymously in a private browser session.

https://1drv.ms/x/s!Arfr_5NFNXw8aPC38X3LUGQI7oU?e=hDQTof

The simulation follows setup as per those listed here -

https://en.m.wikipedia.org/wiki/CHSH_inequality

My simulation is set to test photons with fixed polarization after creation, also the entangled photons would have identical polarization. This is a Local hidden variables simulation.

In running this simulation, CHSH values for S can exceed 2 around 50% of the time, as per real world tests (in real world tests, false negatives and positives suggest that this can impact results, these of course are not possible in the simulation).

The simulation creates 1440 (2880 if you account for the partner photon that is identical) photons with random polarization angles between 0 and 360, ensuring an even distribution. 360 was chosen for ease of measurements; for example, 45 degree polarization is detected the same as 225 degrees, as they have the same polarization.

These photons are then randomly ordered and assigned for measurement, evenly, across the 4 detector combinations (a,b a1,b a,b1 a1,b1), ensuring photons from the ones created, are only measured once.

I was under the impression that if you assume fixed polarization prior to measurement (LHV), then simulations cannot achieve value S>2.

My thinking here is that, due to the combination of separate measurements for detector combinations, can lead to a result where value S>2.

This is an early version of my test simulation in excel (it works well for it and it is quite visual, in that you can see how everything is set up and where results come from. Hopefully not many errors in it, if so, I will correct them following feedback from here).

I appreciate any constructive feedback on this.

Thanks
 
Physics news on Phys.org
  • #2
lostinmygarden said:
I have tried to get chatgpt to replicate my test setup and (as long as it got it right) it also achieved a value of S>2.

https://chatgpt.com/share/72b2c24a-267f-4d9e-be53-9b0af75df663
Don't take ChatGPT seriously here - it is just digesting the same information that you would have found doing your own internet searches and then spitting it back in a plausible-sounding text form, except evaluating it less critically than you would.
(And this is why the forum rules prohibit using ChatGPT as a reference - it's handy shortcut for stuff that is out there and correct already on the internet, and it's good at automateable coding tasks, but it's not going to create, correct, or critically evaluate a model for you).
 
  • #3
Nugatory said:
Don't take ChatGPT seriously here - it is just digesting the same information that you would have found doing your own internet searches and then spitting it back in a plausible-sounding text form, except evaluating it less critically than you would.
(And this is why the forum rules prohibit using ChatGPT as a reference - it's handy shortcut for stuff that is out there and correct already on the internet, and it's good at automateable coding tasks, but it's not going to create, correct, or critically evaluate a model for you).
I have taken the python code and verified it to be correct (I think). Results are consistent with my excel doc simulation. You can extract the code from the chatgpt share too, to examine it. Chatgpt was used just to see if it can replicate my simulation.
Edit: I run the python code extracted from it here https://colab.research.google.com/
 
Last edited:
  • Like
Likes PeroK
  • #4
lostinmygarden said:
Chatgpt was used just to see if it can replicate my simulation.
As mentioned already, it is against the PF rules to use AI chatbots in the technical forums. Please check your Personal Messages (PMs). Thank you.
 
  • #5
berkeman said:
As mentioned already, it is against the PF rules to use AI chatbots in the technical forums. Please check your Personal Messages (PMs). Thank you.
Thanks. The link can be removed. It is only really a reference to the code to be extracted from it that replicates my excel document, nothing more.
 
  • #6
lostinmygarden said:
My simulation is set to test photons with fixed polarization after creation
Which means, as you say, that this is a local hidden variable simulation and will not be able to reproduce the results of actual experiments on actual photons, which match the predictions of QM.

lostinmygarden said:
I was under the impression that if you assume fixed polarization prior to measurement (LHV), then simulations cannot achieve value S>2.
That's true if you simulate correctly. However, your "detector response" function does not appear to be correct.
 
  • Like
Likes Lord Jestocost
  • #7
I hate to be piling on, but this is a big, big ask. "Debug my code for me!" is bad enough, but "Figure out what my code is doing, compare it to this model, and tell me if it is right" is a very big ask indeed.

If you are uncertain about something, I highly recommend you ask about that one thing and not just dump a sack of code on the table. You will get more and better help.
 
  • Like
Likes pines-demon and Motore
  • #8
PeterDonis said:
Which means, as you say, that this is a local hidden variable simulation and will not be able to reproduce the results of actual experiments on actual photons, which match the predictions of QM.


That's true if you simulate correctly. However, your "detector response" function does not appear to be correct.
With reference to the excel document, can you advise on corrections? This is more about the excel simulation. Detector settings are on the settings sheet.
 
  • #9
lostinmygarden said:
With reference to the excel document, can you advise on corrections?
No. I was looking at your Python code.
 
  • #10
PeterDonis said:
No. I was looking at your Python code.
Oh ok. Well I am adjusting that to try and simplify it. Don't really use python much. But if you could take a look at the excel doc, that would be great.
In terms of simplifying python code, I will probably just use angles between 0 and 90 for simulated polarizations of photons. This should make the function to determine detection simpler.
 
  • #11
lostinmygarden said:
if you could take a look at the excel doc, that would be great.
I don't have the time or inclination to try to debug an Excel spreadsheet. I was simply commenting that your detector response function in Python does not look correct. I would expect that whatever corresponds to that in your Excel spreadsheet is also not correct. The way for you to fix that is to think carefully about what a correct detector response function would have to be given the physical meaning of photon polarization.
 
  • #12
I have removed the python code, this is purely on the excel document linked in the post. I think it is correct, I wanted some validation of this.
Thanks
 
  • #13
lostinmygarden said:
I think it is correct
On what basis? What physical model are you simulating?
 
  • #14
lostinmygarden said:
I think it is correct,
There is some basic sanity testing that you can do on your data and detector model before you start calculating CSHS results. For example:
- At all detector settings, the test data produces a roughly equal number of + and - results at both detectors.
- When both detectors are at the same angle they produce the same result every time. This has to be true for all pairs in the data set at all angle settings.
 
  • Like
Likes PeterDonis
  • #15
Nugatory said:
There is some basic sanity testing that you can do on your data and detector model before you start calculating CSHS results. For example:
- At all detector settings, the test data produces a roughly equal number of + and - results at both detectors.
- When both detectors are at the same angle they produce the same result every time. This has to be true for all pairs in the data set at all angle settings.
Hi, yes I have sanity checked this too. I think the calculations are all correct, in that if a photons angle falls between +-45 degrees of a detectors polarizer angle, then it will be detected, if not, it will not. So when detected, result +1 is set, if not, -1 is set. On the sheets from comb1 to comb4, all the results are shown, these appear to be correct.
The tolerances for detection are set within the settings sheet.
As for same detector orientations, these are always excluded from chsh and real world testing, this is because they will always match, which they would do in the simulation too.
I've done as much as I can do to qa my own work, but proper qa should never be done by the creator.
I can share an editable version of this, that would make it possible to set whatever you wanted. Alternatively, I think you can just download a copy of it.
 
  • #16
PeterDonis said:
On what basis? What physical model are you simulating?
In real world tests, with a large enough data set, in theory, you would get an even distribution of photons around 360 degrees (this is all on the premise that photons have a set polarization after creation). Of course, it is not strictly 360 degrees, as, for example, 30 degrees is the same as 210 degrees in terms of polarization. This is all accounted for though.
So the simulation just tests randomly generated polarized photons against the chsh inequality experiment, as per the Wikipedia article. In the real world, Photon pairs are tested against 4 detector combinations. The results are gathered together and then E data is calculated, then an S value from this is determined.
 
  • #17
lostinmygarden said:
if a photons angle falls between +-45 degrees of a detectors polarizer angle, then it will be detected, if not, it will not
That's not what the Python detector response function you posted was doing.
 
  • #18
PeterDonis said:
That's not what the Python detector response function you posted was doing.
I have changed the python code, but not what this post was about.
My modified python code does this detection and reduces from 0 to 359, to 0 to 89 degrees (plus random value between 0 and 1) for photon creation.
This is solely about the excel document. I can post the updated python code, but it is not what the post is about.
 
  • #19
lostinmygarden said:
I have changed the python code, but not what this post was about.
My modified python code does this detection and reduces from 0 to 359, to 0 to 89 degrees (plus random value between 0 and 1) for photon creation.
This is solely about the excel document. I can post the updated python code, but it is not what the post is about.
What is this post about?
 
  • #20
lostinmygarden said:
I have changed the python code, but not what this post was about.
Does your Excel spreadsheet use the same detector response algorithm that was in the Python code you posted? If so, it's wrong.

lostinmygarden said:
My modified python code does this detection and reduces from 0 to 359, to 0 to 89 degrees
Restricting the polarization angles you generate for the photons has nothing to do with whether or not your detector response function is correct.
 
  • #21
PeterDonis said:
Does your Excel spreadsheet use the same detector response algorithm that was in the Python code you posted? If so, it's wrong.


Restricting the polarization angles you generate for the photons has nothing to do with whether or not your detector response function is correct.
I think you will find it does.
 
  • #22
PeterDonis said:
Does your Excel spreadsheet use the same detector response algorithm that was in the Python code you posted? If so, it's wrong.


Restricting the polarization angles you generate for the photons has nothing to do with whether or not your detector response function is correct.
If you have not checked excel, then you can conclude nothing
 
  • #23
PeterDonis said:
Does your Excel spreadsheet use the same detector response algorithm that was in the Python code you posted? If so, it's wrong.


Restricting the polarization angles you generate for the photons has nothing to do with whether or not your detector response function is correct.
Polarization is considered to be the same if you take the negative of an angle. Also, if you +180 to an angle, it has the same polarization. Going from 360 to 90 means detection is only needed between 0-45 and 90+45. Of course, realistically you only determine between 0 and 90. So yes, detection angles need to be changed, otherwise they are out of scope.
For some reason you are stuck on this python code thing and ignorant of the post request. All of the information you are asking is on the excel document, I can't make it any easier for you I'm afraid.
 
  • #24
lostinmygarden said:
For some reason you are stuck on this python code thing and ignorant of the post request. All of the information you are asking is on the excel document, I can't make it any easier for you I'm afraid.
Yes, you can make it easier and universal by using standard mathematics to post (in LaTeX) the equations that underlie your analysis, so that we may understand independent of any particular coding environment (Python, Excel, etc.).
 
  • Like
Likes Vanadium 50, berkeman, PeterDonis and 1 other person
  • #25
renormalize said:
Yes, you can make it easier and universal by using standard mathematics to post (in LaTeX) the equations that underlie your analysis, so that we may understand independent of any particular coding environment (Python, Excel, etc.).
orientationpolarizer angledetection fromdetection todetection fromdetection to
a
0​
315​
45​
135​
225​
a1
45​
0​
90​
180​
270​
b
22.5​
337.5​
67.5​
157.5​
247.5​
b1
67.5​
22.5​
112.5​
202.5​
292.5​
 
  • #26
lostinmygarden said:
orientationpolarizer angledetection fromdetection todetection fromdetection to
a
0​
315​
45​
135​
225​
a1
45​
0​
90​
180​
270​
b
22.5​
337.5​
67.5​
157.5​
247.5​
b1
67.5​
22.5​
112.5​
202.5​
292.5​
I'd need to get familiar with LaTeX. I have just included the ranges of detection for now.
So a +-45, b +-45, a1 +-45, b1 +-45
No negative numbers for angles, so 0-45 same as 360-45 and 22.5-45 same as 360-22.5.
 
  • #27
lostinmygarden said:
I think you will find it does.
I think you will find that if it does it means your model is incorrect.

lostinmygarden said:
Polarization is considered to be the same if you take the negative of an angle.
Not in general, no. Minus 10 degrees is not the same polarization as plus 10 degrees.

lostinmygarden said:
Also, if you +180 to an angle, it has the same polarization.
For photons, yes. Not for particles that have any spin other than spin-1.

lostinmygarden said:
For some reason you are stuck on this python code thing
No, I took the incorrectness of the python code as grounds for suspecting that other things that you are doing are incorrect as well. So far my suspicions appear to have been warranted.

lostinmygarden said:
ignorant of the post request
Pointing out incorrect statements you are making about polarization is relevant to your OP request.
 
  • #28
PeterDonis said:
I think you will find that if it does it means your model is incorrect.


Not in general, no. Minus 10 degrees is not the same polarization as plus 10 degrees.


For photons, yes. Not for particles that have any spin other than spin-1.


No, I took the incorrectness of the python code as grounds for suspecting that other things that you are doing are incorrect as well. So far my suspicions appear to have been warranted.


Pointing out incorrect statements you are making about polarization is relevant to your OP request.
And you keep referring to python code that was removed, because I want focus on my excel document.
PeterDonis said:
I think you will find that if it does it means your model is incorrect.


Not in general, no. Minus 10 degrees is not the same polarization as plus 10 degrees.


For photons, yes. Not for particles that have any spin other than spin-1.


No, I took the incorrectness of the python code as grounds for suspecting that other things that you are doing are incorrect as well. So far my suspicions appear to have been warranted.


Pointing out incorrect statements you are making about polarization is relevant to your OP request.
See, now you are talking about electron spin, where did I ever mention that? You have not read my post, clearly, or my document. You keep referring to python, like it is referenced in my post.

[Post edited by the Mentors]
 
Last edited by a moderator:
  • #29
Thread is closed briefly for Moderation and cleanup...
 
  • Like
Likes Vanadium 50
  • #30
After some cleanup, the thread is reopened provisionally. @lostinmygarden -- please check your PMs.
 
  • #31
Polarization angles and their negative angle counterparts, are detected as the same polarization.
30 and -30 (330), 10 and -10 (350) degrees would all be detected as vertical polarization on detector, with a 0 degrees polarizater orientation. It cannot differentiate between them, so sees them as the same polarization.
 
  • #32
lostinmygarden said:
Polarization angles and their negative angle counterparts, are detected as the same polarization.
30 and -30 (330), 10 and -10 (350) degrees would all be detected as vertical polarization on detector, with a 0 degrees polarizater orientation. It cannot differentiate between them, so sees them as the same polarization.
This is not how actual detection of polarization works. If your model can't even reproduce the correct results for a single polarization detector being fed a stream of photons polarized at an angle to the detector angle, it's a useless model.
 
  • #33
PeterDonis said:
This is not how actual detection of polarization works. If your model can't even reproduce the correct results for a single polarization detector being fed a stream of photons polarized at an angle to the detector angle, it's a useless model.
Have you looked at my document yet? Or are your comments based off your assumptions?
 
  • #34
lostinmygarden said:
Have you looked at my document yet?
No.

lostinmygarden said:
Or are your comments based off your assumptions?
No. They're based off your explicit statements, which I explicitly quoted.
 
  • #35
PeterDonis said:
This is not how actual detection of polarization works. If your model can't even reproduce the correct results for a single polarization detector being fed a stream of photons polarized at an angle to the detector angle, it's a useless model.
A photon that is mostly vertically aligned to a polarizer, will/should be detected as vertically polarized.
PeterDonis said:
No.


No. They're based off your explicit statements, which I explicitly quoted.
You may have quoted, but you are wrong in your conclusions. I clearly state measurement criteria in my document (which you have not looked at).
A photon that has polarization which is mostly aligned to a polarizer (+-45 degrees) will be detected. If it does not, then it is not detected and assumed to be mostly horizontal against alignment to the polarizer (real world testing cannot actually detect both, as a measurement can only be taken once).
This is why detection on a single detector is 50%. A photon is either mostly aligned to the detector, or it is mostly not aligned.
For example, given a detector at 0 degrees -
A photon at 10 degrees will be detected (it is within +-45 degrees of 0).
A photon at 46 degrees will not be detected (it is not within +-45 degrees of 0)
 
Back
Top