Probability distribution confusion

yuiop
Messages
3,962
Reaction score
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 \theta and \pi/4 defined by:

p = \int_{a= \theta}^{a=\pi/2} \cos(2a),\qquad da

...where \theta will normally have a value between -\pi/4 and \pi/4. 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?
 
Physics news on Phys.org
You need two things:

A. a uniform pseudo-random generator (I'll call this uniform random variable u)

B. a closed-form solution for your integral, F[θ], that you can invert at least locally (i.e. for -π/4 < θ < π/4).

I will assume that you have both A and B, and that F is a well-behaved CDF (i.e. monotone increasing, F[-π/4] = 0, F[π/4] = 1) -- you should verify these. Then:

1. generate a list of draws from u, {u1, ..., un}

2. for each u value, calculate θj = F-1[uj] to obtain a list of θ values. Those values will be distributed F.

If you don't have a closed-form integral then you may have to numerically calculate each θj.
 
Last edited:
EnumaElish said:
You need two things:

A. a uniform pseudo-random generator (I'll call this uniform random variable u)
Got one of those :smile:

EnumaElish said:
B. a closed-form solution for your integral, F[θ], that you can invert at least locally (i.e. for -π/4 < θ < π/4).

Not quite sure what you mean here. The indefinite integral of cos(2*a) is sin(a)*cos(a). Not quite sure where to go from there either. If I call it u = sin(a)*cos(a) and try to solve for a, I get a fairly complicated result http://www.wolframalpha.com/input/?i=solve+u=+sin(a)+cos(a)+1/2+for+a. Is that what you are referring to?

EnumaElish said:
I will assume that you have both A and B, and that F is a well-behaved CDF (i.e. monotone increasing, F[-π/4] = 0, F[π/4] = 1) -- you should verify these.
I have plot for u = sin(a)*cos(a)+1/2 that smoothly increases from 0 to 1 over that range. It can be seen here
http://www.wolframalpha.com/input/?i=plot+cos(2*a),+sin(a)+cos(a)+1/2+from+a=-pi/4+to+pi/4 alongside a plot for cos(2*a) which does not match your criteria.

EnumaElish said:
Then:

1. generate a list of draws from u, {u1, ..., un}

2. for each u value, calculate θj = F-1[uj] to obtain a list of θ values. Those values will be distributed F.

If you don't have a closed-form integral then you may have to numerically calculate each θj.
Is the complicated solution for a in the Wolfram Alpha link, the F-1[uj] you speak of?
 
Last edited:
EnumaElish said:
You need two things:

A. a uniform pseudo-random generator (I'll call this uniform random variable u)

B. a closed-form solution for your integral, F[θ], that you can invert at least locally (i.e. for -π/4 < θ < π/4).

I will assume that you have both A and B, and that F is a well-behaved CDF (i.e. monotone increasing, F[-π/4] = 0, F[π/4] = 1) -- you should verify these. Then:

1. generate a list of draws from u, {u1, ..., un}

2. for each u value, calculate θj = F-1[uj] to obtain a list of θ values. Those values will be distributed F.

If you don't have a closed-form integral then you may have to numerically calculate each θj.

O.K. I managed to get a slightly simpler solution http://www.wolframalpha.com/input/?i=solve+v=+sin(a)+cos(a)+for+a by using v=cos(a)*sin(a) and solving for a, using v as a substitution for u-1/2. This produced a good match to the theoretical distribution using pseudo-random data. Thanks for the help. You obviously know what you are doing. :wink: Cheers! :smile:
 
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Thread 'Detail of Diagonalization Lemma'
The following is more or less taken from page 6 of C. Smorynski's "Self-Reference and Modal Logic". (Springer, 1985) (I couldn't get raised brackets to indicate codification (Gödel numbering), so I use a box. The overline is assigning a name. The detail I would like clarification on is in the second step in the last line, where we have an m-overlined, and we substitute the expression for m. Are we saying that the name of a coded term is the same as the coded term? Thanks in advance.

Similar threads

Replies
18
Views
3K
Replies
9
Views
2K
Replies
10
Views
2K
Replies
2
Views
2K
Replies
1
Views
1K
Replies
3
Views
2K
Back
Top