Probability distribution confusion

Click For Summary

Discussion Overview

The discussion revolves around the challenges of implementing a Monte Carlo simulation for generating photon angles based on a specified probability distribution. Participants explore the mathematical formulation of the probability function and the requirements for generating random angles that conform to this distribution.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant presents a probability function for photon angles defined by an integral, noting that the probability of an exact angle is zero and questioning whether differentiation is necessary.
  • Another participant suggests the need for a uniform pseudo-random generator and a closed-form solution for the integral to generate angles that match the desired distribution.
  • A different participant expresses uncertainty about the closed-form solution, mentioning the indefinite integral of cos(2a) and the complexity of solving for angle a.
  • One participant shares a plot that shows the behavior of the cumulative distribution function (CDF) and questions whether the complicated solution for a is the inverse function needed for generating angles.
  • Another participant reports success in simplifying the solution for angle a using a substitution method, indicating that it produced a good match to the theoretical distribution with pseudo-random data.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to derive the closed-form solution for the integral, and there are varying levels of understanding regarding the mathematical steps involved. Some participants express uncertainty and seek clarification, while others provide solutions that appear to work for them.

Contextual Notes

There are unresolved mathematical steps regarding the integration and inversion of functions, as well as dependencies on the definitions of the probability distribution and the random number generation process.

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:
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
990