FrediFizzx wrote:Joy Christian wrote:FrediFizzx wrote:minkwe wrote:Yes, There are M entries in X and 51 entries in Y, so it loops around Y. Try returning cos (random angle) instead of cos (Angles) and see if that still works.Because the corresponding angle whose cosine is being returned has nothing to do with Alpha, or Beta, that is why cos(alpha) did not work.
Well, I have to figure out how to setup random angles in R but I don't expect it to work. But Mathematica does work with random angles with a slightly different process. Somehow the iteration loops in R are lining up properly using cos(Angles) in the q-function. And it still works if I set the fixed angles to 5 degree resolution instead of 7.2.
It might be more worthwhile to try to get alpha and beta working because it seems to me that they should work also now that I see the proper way to do them in the q-function. Thanks for that.
I just tried g-old and g-new = p x q in the same simulation (alternatively) in R, and both g-functions are producing exactly the same plots, as well as exactly the same numbers for various quantities like A, B, p, q, etc. I find that very curious.
***
Joy, try this to see if you get any clues as to why alpha and beta are not working correctly from the resulting plot.
- Code: Select all
A = +sign(h(a,e)*g(a,e,alpha)) # Alice's results A(a, e, s) = +/-1
B = -sign(h(b,e)*g(b,e,beta)) # Bob's results B(b, e, s) = -/+1
with the h and g-functions being,
h = function(p,q){colSums(p*q)} # polarizer function
g = function(u,v,w){ifelse(abs(h(u,v)) > f, cos(w), 0)}
I believe that is the correct way of doing alpha and beta. Michel?
.
Yes, based on what both of you have told me, about the model, you should be doing
- Code: Select all
h = function(p,q){colSums(p*q)} # polarizer function
g = function(u,v,w){ifelse(abs(h(u,v)) > f, cos(w), 0)}
A = +sign(h(a,e)*g(a,e,alpha)) # Alice's results A(a, e, s) = +/-1
B = -sign(h(b,e)*g(b,e,beta)) # Bob's results B(b, e, s) = -/+1
not what is currently being done in the R-code.
replace cos(Angles) with cos(runif(M, 0, 2*pi)) in the R-code and see what it does. Like so:
- Code: Select all
ANG = runif(M, 0, 2*pi) # random angles
g = function(u,v,w){ifelse(abs(h(u,v)) > f, cos(ANG), 0)}
You'll see that it produces exactly the same results as cos(Angles). Then replace the g function with
- Code: Select all
g = function(u,v,w){ifelse(abs(h(u,v)) > f, f, 0)}
You'll see that it makes no difference! Same results. In fact, the following also produces the exact same results:
- Code: Select all
g = function(u,v,w){ifelse(abs(h(u,v)) > f, 1, 0)}
- Code: Select all
g = function(u,v,w){max(sign(abs(h(u,v)) - f), 0)}
Do you recognize the last function?