I am trying to simulate (MonteCarlo integrate) the following scenario, see sketch below (as prequel of a somewhat bigger simulation).

enter image description here

Assume a small (point) L'Ambertian emitter, i.e. the radiant intensity is distributed as cosine $I=I_0 cos(\theta)$. In a distance $d$ and coaxially, there is a circular aperture of width $a$. How does the total power $\Phi$ transferred from the source to the aperture decrease with distance? We know, that at large distance one should obtain an inverse square law $\Phi \propto 1/d^2$.

This is how I tried to code:

i) Generate N samples (i.e. rays, actually just their emission angles) with distribution $cos(\theta)$. enter image description here

ii) Count only those samples/rays, that have a value $\theta < \theta_{max} = \arctan(\frac{a}{2d})$

iii) Do that for all distances and plot the counted samples from ii) as function of distance, see image below.

enter image description here

The problem; Only when I square the count values I obtain an inverse square dependence. Actually, it even reproduces a textbook expression for small $d$.

Question: It seems that my sketch is only 2Dimensional, while the inv.-square law refers to 3D space. But, I cannot rationalize why I suddenly have to square the counts. Do I have to setup the sampling differently to get the right dependence directly? I would appreciate if someone could point out (formally) where this squaring comes from.

Thank you!

  • $\begingroup$ maybe anderswallin.net/2009/05/… ? $\endgroup$
    – Kyle Kanos
    Commented Sep 23, 2019 at 17:29
  • $\begingroup$ This probably isn't the right way to simulate the inverse square law. It is a known fact that energy is conserved. This means that for a constant power source, and for a constant aperture, a constant amount of power exits that aperture. The intensity of measured energy is proportional to the power exiting the aperture divided by the area that the energy has to cover. $\endgroup$ Commented Sep 23, 2019 at 17:30
  • $\begingroup$ physics.stackexchange.com/a/497304/1194 does this help? $\endgroup$
    – boyfarrell
    Commented Nov 1, 2019 at 19:06

1 Answer 1


By choosing only a single uniform parameter ($\theta$), you are effectively simulating the distribution along a 2D circle. But your emitter is a 3D emitter. So you should be creating either a distribution that is uniform on the surface of a sphere, or use two separate angles (such as $\theta$ and $\phi$) with the appropriate limits.

  • $\begingroup$ if i do that, assuming radial symmetry w.r.t. angle $\phi$, for each sample i would get another random number in [0,2$\pi$]. then, i would go on to step ii) from the original post, and just end up with the same number of samples that have small enough $\theta$. am i getting this wrong? $\endgroup$
    – bebissig
    Commented Sep 23, 2019 at 19:43
  • $\begingroup$ @bebissig, does $\theta$ represent the (3D) angle from the ray to the normal, or does it represent only the "on page vertical" angle from the normal (similar to the "latitude" of the ray)? $\endgroup$
    – BowlOfRed
    Commented Sep 23, 2019 at 22:57
  • $\begingroup$ maybe you pointed me thr right way. i have to understand it as the 3d angle, a delta-theta then is sort of a slice/ring on the hemisphere. in that case i think i have to sample from sin(theta)*cos(theta), accounting for the rings getting smaller in forward direction, does that sound right? in that case i obtain the expected 1/r^2 behavior... if that sounds reasonable i would add the solution in my question and accept your answer... $\endgroup$
    – bebissig
    Commented Sep 24, 2019 at 15:08
  • $\begingroup$ That's correct. If it's the 2D angle, then the initial test you had in step ii is incorrect. If it's the 3D angle then the distribution you had is incorrect. You can solve it by fixing one or the other. $\endgroup$
    – BowlOfRed
    Commented Sep 24, 2019 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.