- #1
yuiop
- 3,962
- 20
Hi, I am trying to write a Monte Carlo type simulation. I have a function for the probability (p) of a photon having an angle (a) between [itex]\theta[/itex] and [itex]\pi/4[/itex] defined by:
[tex]p = \int_{a= \theta}^{a=\pi/2} \cos(2a),\qquad da [/tex]
...where [itex]\theta[/itex] will normally have a value between [itex]-\pi/4[/itex] and [itex]\pi/4[/itex]. One immediate problem with the above equation is that the probability of producing a photon of a given exact angle is exactly zero. Do I need to differentiate the equation? Now what I want to do is use a random number generator to produce photons with angles that will match the distribution above when large numbers of photons are produced, but I am having difficulties achieving this. Can anyone offer any suggestions to help me out here?
P.S. If I have posted this question in the wrong forum please advise. I was wondering if it should be in the calculus forum?
[tex]p = \int_{a= \theta}^{a=\pi/2} \cos(2a),\qquad da [/tex]
...where [itex]\theta[/itex] will normally have a value between [itex]-\pi/4[/itex] and [itex]\pi/4[/itex]. One immediate problem with the above equation is that the probability of producing a photon of a given exact angle is exactly zero. Do I need to differentiate the equation? Now what I want to do is use a random number generator to produce photons with angles that will match the distribution above when large numbers of photons are produced, but I am having difficulties achieving this. Can anyone offer any suggestions to help me out here?
P.S. If I have posted this question in the wrong forum please advise. I was wondering if it should be in the calculus forum?