# Variance reduction techniques in GamBet

The GamBet software suite calculates the interactions of energetic photons, electrons and positrons with matter. In a previous sequence of three articles (Monte Carlo methods versus moment equations: Part A, Part B and Part C), I discussed how Monte Carlo calculations approximate the behavior of large collections of particles. The essence of the Monte Carlo method is to follow the interactions of a finite set of model particles with the assumption that they represent the average behavior of the large set. The advantage is that there is a close connection with the interaction physics, so that a Monte Carlo calculation is often called a simulation. The disadvantage is that it is a statistical process, so the accuracy of predictions is limited by random variations set by the number of model particles or events, N. The accuracy in estimating an average quantity is usually expressed as <x> ± ?, where <x> is the ideal average and ? is the standard deviation set by the finite number of samples. The standard deviation equals the square root of the variance, the average of the squared differences from the mean value. The standard deviation scales as 1/?N. Improving the accuracy of estimates by a factor of 10 requires 100 times the number of model particles. The implication is that high accuracy leads to long run times.

The term variance reduction[1] applies to methods to optimize Monte Carlo calculations to gain an edge on the 1/?N limit. Variance reduction is not a formalized mathematical method, but rather a set of common-sense fixes that can go a long way toward reducing run time. The essence is finding ways not to waste time on particles that will not contribute to critical results. The success and validity of variance reduction depends strongly on user judgements. GamBet uses the Penelope package for interaction physics. Penelope has built-in features for variance reduction that are implemented in GamBet with the following commands:

`ENHANCE NReg NSplit [ElecP, PhotP, PosiP, ElecS, PhotS, PosiS]`

GamBet is unique among Monte Carlo codes in its use of a finite-element conformal meshes to represent the solution volume. Users can divide the space into a number of regions to represent different materials or sections of an object. The Enhance command improves statistics in a critical region (such as a detector). Particles entering the region are split into NSplit particles with statistical weight 1/NSplit. With the optional string parameters, the operation may be limited to specific particle types (primary or secondary electrons, photons and positrons).

`REDUCE NReg NKill [ElecP, PhotP, PosiP, ElecS, PhotS, PosiS]`

The Reduce command is the inverse of Enhance. The number of particle entering a specified non-critical region are reduced while increasing their statistical weight.

`FORCE [ELEC,PHOT,POSI] [HELAS,...]  Factor [NReg]`

This command instructs the program to increase the probability of low-probability interactions like bremsstrahlung emission. The statistical weight of reaction products is decreased to preserve the correct energy balance between reactions.

Beyond the Penelope techniques, GamBet is structured to help achieve short run times.  The code was designed to encourage the division of calculations into manageable segments. For example, an initial segment could address a radioactive source with shielding and collimation, while a second segment could address the interaction of forward-directed radiation with tissue. The segments are connected by an escape file which records the set of model particles that reach the boundary of the first segment. The key to variance reduction in GamBet is filtering and transforming escape files for optimal performance in a following segment. The escape distribution can be modified within a GamBet run with the following command:

`ESCAPEFILTER Condition01 Condition02 ...`

The conditions are strings like X>0.15, T<5.0E6,…. Particles must meet the combined conditions to be included in the escape file. Conditions may apply to spatial locations, kinetic energy and particle type. The idea is to limit particles to those that will play a role in the following segment and to limit the size of the escape file. Recently we expanded the EscapeFilter conditions to include particle direction: Ux>0.1,Uz>0.95,Ur<0.25,… Here, the quantities are the components of a unit vector pointing along the direction of the velocity. One application is to limit particles to those that are aimed toward a detector or target.

Figure 1. GenDist as a component in a variance reduction strategy.

The GamBet package includes GenDist, a powerful utility to create or to modify large particle distributions. GenDist can act as an additional stage between calculation segments (Figure 1) to optimize particle properties for reduced variance. The basic sequence is to read an escape file, filter or transform the particle parameters and to write a modify file to be used as the source for a following calculation segment. In the past, the operations were controlled interactively by the user in a program window. We have recently added a script capability for autonomous production runs. Here is a summary of the new script commands:

READ FPrefix.SRC
Load an escape file

WRITE Fprefix.SRC
Write a file of transformed particle parameters, applying any filter conditions that have been set.

AXIS [X,Y,Z]
Set a reference axis for evaluating transverse velocity in transformations and filters.

FILTER Condition Value
Set any number of filter conditions. The set of conditions is the same as those in the GamBet EscapeFilter command.

XFORM GENERAL XShift YShift ZShift XRotate YRotate ZRotate
Move or rotate the particles to match the coordinate system of the next computational segment.

XFORM UNIDIST Dist
XFORM NORMPLANE Pos
XFORM CLOSETOLINE HLine YLine
Move particles in ballistic orbits following their velocity vectors. The options are shifts 1) a uniform distance backward or forward, 2) to a plane normal to the current axis or 3) to their positions closest to a line parallel to the current axis. One main application is to find the effective radius of a bremsstrahlung source for X-ray imaging applications by back-projection to the target.

BEAMSECT2D NThet
BEAMSECT3D X 0 X X
The first command converts a distribution from 2D cylindrical calculation to one suitable for a 3D calculation. The second command limits 3D beam distributions to specific transverse quadrants or mirrors a beam distribution.

SCALE Fact
Change the size of a particle beam or convert spatial units to match calculation segments. For example, a source calculation may use units of mm, but units of m may be more appropriate for the detector calculation.

For more details, use these links to download the GamBet and GenDist manuals. Free updates to the new programs are available to GamBet and Xenos users.

Footnotes

[1] The term standard deviation reduction would be a better choice, but it is a less compelling phrase.

[2] Contact us : techinfo@fieldp.com.

[3] Field Precision home page: www.fieldp.com.

Comments are closed.