Introduction
In our last session, we established a method to determine the type of interaction a particle undergoes at a collision site. We now turn our attention to the consequences of that interaction. Assuming our "roulette wheel" has selected Compton scattering, our task is to determine the photon's new energy and direction. This step is a cornerstone of photon transport simulation, as it dictates the particle's subsequent path and its potential to cause further interactions.
This lesson will guide you through the process of sampling the post-collision state for a Compton event. We will see that the outgoing energy and the scattering angle are uniquely linked by conservation laws. The core challenge lies in sampling this scattering angle from its governing probability distribution, the famous Klein-Nishina formula. Since this distribution is too complex for the inverse transform method we've used previously, we will introduce a powerful and general Monte Carlo technique: rejection sampling.
The Physics of the Post-Collision State
From your physics background, you'll recall that in Compton scattering, the relationship between the incoming photon energy, , the outgoing photon energy, , and the polar scattering angle, , is given by:
Here, is the incident photon energy in units of electron rest mass energy (0.511 MeV). This equation shows a deterministic, one-to-one mapping: if we know the scattering angle , we can immediately calculate the new energy . Therefore, our primary task is to stochastically sample .
The probability of a photon scattering into a particular solid angle is described by the Klein-Nishina differential cross section, . After normalization, this cross section becomes the probability density function (PDF) from which we must sample .
The following video provides an excellent walkthrough of the Klein-Nishina formula and its role as a PDF. It uses the Python library SymPy to perform the derivations, which you may find particularly interesting.
Compton Scattering in Python (Klein-Nishima Equation)
This video, "Compton Scattering in Python," clearly explains the connection between the physical cross section and the probability distribution for the scattering angle.
First, watch the conceptual introduction to differential cross section from the start of the explanation. This will solidify the idea of d\sigma/d\Omega as a measure of scattering probability into a certain direction. Next, see how the PDF for the polar angle, f(\theta), is derived by integrating over the azimuthal angle and normalizing by the total cross section. Focus on the explanation from deriving d-sigma/d-theta and the subsequent normalization discussion from finding the PDF. Finally, observe the animation from "let's make an animation". It beautifully visualizes how the angular distribution changes with incident energy, becoming increasingly peaked in the forward direction as energy increases.
The animation in the video is complemented by the static polar plot below, which shows the same effect for several discrete energies.

Sampling from the Klein-Nishina PDF: Rejection Sampling
The mathematical form of the Klein-Nishina PDF is complex, making it impractical to integrate and invert to create a cumulative distribution function (CDF) for inverse transform sampling. This is a common problem in Monte Carlo simulations. The solution is a versatile technique known as rejection sampling (or the acceptance-rejection method).
The principle is simple:
- Identify a simpler "proposal" probability density function, , that we can easily sample from. This function must be "larger" than our target PDF, , everywhere; that is, for all , where is a constant. A uniform distribution is often a convenient choice for .
- Sample a random value from the proposal distribution .
- Generate a second random number, , from a uniform distribution .
- Accept if . Otherwise, reject and return to step 2.
The set of accepted samples will be distributed according to the target PDF, . The following resource provides a concise explanation of this method and shows its direct application to sampling the Compton scattering angle.
[PDF] Monte Carlo Simulation of Gamma Rays
This document outlines a simple gamma-ray Monte Carlo simulation and explicitly details the use of rejection sampling for the Compton angle.
Begin by reading the section "The problem is..." on page 1, which introduces the acceptance-rejection method. Next, in the Appendix on page 6, examine the Python implementation. The function monte_carlos is a general rejection sampler. See how it is used in the main path function to sample the scattering angle: sc_theta=monte_carlos(partial(p_theta,g=E[-1]),...). The p_theta function just above it defines the normalized Klein-Nishina PDF. This shows the practical application of the theory.
While the generic rejection sampler shown in the PDF works, its efficiency depends heavily on how closely the proposal distribution matches the target . For widely used distributions like Klein-Nishina, highly optimized and efficient rejection algorithms have been developed. Professional transport codes like OpenMC use these specialized methods.
6. Photon Physics — OpenMC Documentation
The OpenMC documentation gives a glimpse into how a production-grade code handles this sampling problem.
Read the section Incoherent (Compton) Scattering. Note the mention of "Kahn’s rejection method" and a "direct method by Koblinger." These are famous, optimized algorithms specifically for the Klein-Nishina formula that ensure high computational efficiency. You don't need to implement them now, but it's important to know they exist.
Determining the New Energy and Direction
With a method to sample the polar scattering angle , we have almost everything we need. The process to define the new photon state is as follows:
- Sample the polar angle : Use a rejection sampling algorithm for the Klein-Nishina PDF corresponding to the photon's incident energy .
- Calculate the new energy : Use the Compton scattering formula with the sampled .
- Sample the azimuthal angle : The scattering process is symmetric around the incident direction. Therefore, the azimuthal angle is sampled uniformly from the interval .
where .
It's crucial to understand that sampling uniformly would be incorrect. It would lead to an over-sampling of scattering events near the "poles" ( and ) and under-sampling near the "equator" (). The image below illustrates this common pitfall in spherical coordinate sampling.

Coordinate System Rotation
The final, critical step is to determine the photon's new direction vector, , in the fixed laboratory coordinate system. The angles we just sampled are defined in a local coordinate system where the z'-axis is aligned with the photon's incident direction, . We must rotate the new local direction into the global lab frame.
Let the incident direction vector be . We define a local orthonormal basis :
- To define and , we need a robust method that avoids issues when is nearly parallel to the lab z-axis. A standard algorithm is:
- If (where is a small tolerance, e.g., ), the incident vector is not aligned with the z-axis. We can define the local x'-axis in the lab xy-plane:
- If , the incident vector is aligned with the z-axis. We can simply align the local axes with the lab axes:
- The local y'-axis is then found by the cross product:
- If (where is a small tolerance, e.g., ), the incident vector is not aligned with the z-axis. We can define the local x'-axis in the lab xy-plane:
The new direction vector in the local frame is .
The final direction vector in the lab frame, , is obtained by projecting this local vector onto the lab basis vectors using our new local basis:
This is a vector addition where are the vectors you calculated above. This rotation correctly updates the photon's direction for the next step of its journey.
Conclusion
We have now assembled the complete logic for simulating a Compton scattering event. By combining the physics of the Klein-Nishina formula with the computational technique of rejection sampling, we can accurately determine the photon's state after the interaction.
Key Takeaways:
- The post-Compton scattering state is defined by a new energy and direction .
- The scattering angle and are linked by the Compton formula, so sampling one determines the other.
- The Klein-Nishina distribution, which governs , is too complex for inverse transform sampling, necessitating the use of rejection sampling.
- The azimuthal angle is sampled uniformly from due to physical symmetry.
- A coordinate rotation is required to transform the new direction vector from the particle's local frame back into the fixed laboratory frame.
Preview of the Next Lesson:
Our photon can now be born, travel, and scatter. But a particle's life doesn't go on forever. In the next lesson, we will address particle termination events, such as absorption (e.g., photoelectric effect), escape from the problem geometry, and falling below a predefined energy cutoff. This will be the next-to-last component needed to simulate a full particle history.