Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • $\begingroup$ I really appreciate you spending the time to help me. Each grating has 2^n slits, and the photons could go through any of these slits. The uDL variables are lists of lists of unitstep functions, where the inner list has length 2^n, and the outer list has length = numGratings. I think you replaced the inner list of possible slits with a single slit. $\endgroup$ Commented Feb 14 at 18:04
  • $\begingroup$ But this gives me an idea. I'll create a new list, uDL2, as uDL2 = Table[ Sum[uDL[[i, j]], {j, 1, Length[uDL[[i]]]}], {i, Length[uDL]}];. Now I don't have an inner list, but just a sum of uniform distributions. I'll see if this is faster $\endgroup$ Commented Feb 14 at 18:05
  • $\begingroup$ I'm also going to use RandomVariate[dist, {tryCount, numGratings^2}] to speed up the random number generation. $\endgroup$ Commented Feb 14 at 18:06
  • $\begingroup$ No, I didn't replace inner lists with single slits. I came up with a different concept for how to check whether a photon when through a slit. Rather than check a bunch of piecewise functions individually, I exploited the translational symmetry. Now, I may have made a mistake in implementing it, but I think the idea is sound. $\endgroup$ Commented Feb 14 at 18:31
  • $\begingroup$ But, in my opinion you're probably fighting a losing battle with your approach. You have loops nested 4 levels deep. I really suggest you go back to the drawing board and come up with a loop-free (or loop minimized) strategy. Or write your code in C instead. $\endgroup$ Commented Feb 14 at 18:34