# Guide Introduction to Monte Carlo Algorithms

The name is thus quite appropriate as it captures the flavour of what the method does. The method itself, which some famous mathematicians helped to develop and formalize Fermi, Ulam, von Neumann, Metropolis and others was critical in the research carried on in developing the atomic bomb it was used to study the probabilistic behaviour of neutron transport in fissile materials and its popularity in modern science has a lot to do with computers von Neumann himself built some of the first computers.

Without the use of a computer, Monte Carlo integration is tedious as it requires tons of calculations, which obviously computers are very good at. Now that we have reviewed some history and gave some information about the origin of the method's name, let's explain what Monte Carlo is. Unfortunately though as briefly mentioned before, the mathematical meaning of the Monte Carlo method is based on many important concepts from statistics and probability theory. We will first have to review these concepts and introduce them to you before looking at the Monte Carlo method itself.

What is Monte Carlo? The concept behind MC methods is both simple and robust. However as we will see very soon, it requires potentially massive amount of computation, which is the reason its rise in popularity coincides with the advent of computing technology. Many things in life are too hard to evaluate exactly especially when it involves very large numbers.

For example, while not impossible, it could take a very long time to count the number of Jelly beans that a 1 Kg jar may contain. You might count them by hand, one by one, but this might take a very long time as well as not being the most gratifying job ever. Calculating the average height of the adult population of a country, would require to measure the height of each person making up that population, summing up the numbers and dividing them by total number of people measured.

Again, a task that might take a very long time. What we can do instead is take a sample of that population and compute its average height.

## Monte Carlo method

It is unlikely to give you the exact average height of the entire population, however this technique gives a result which is generally a good approximation of what that number is. We traded off accuracy for speed. Polls also known as statistics are based on this principle which we are all intuitively familiar with. Funnily enough the approximation and the exact average of the entire population might some times be exactly the same.

This is only due to chance. In most cases, the numbers will be different. One question we might want to ask though, is how different? In fact, as the size of the sample increases, this approximation converges to the exact number. In other words, the error between the approximation and the actual result, is getting smaller as the sample size increases. Intuitively, this idea is easy to grasp, however we will see in the next chapter, that it should be from a mathematical point of view formulated or interpreted differently.

Note that to be fair, elements making the sample need to be chosen randomly with equal probability. Note that the height of a person is a random number. It can be anything really which is the nature of random things. Thus, when you sample a population, by randomly picking up elements of that population and measuring their height to approximate the average height, each measure is a random number since each person from your sample is likely to have a different height.

Interestingly enough, a sum of random numbers, is another random number. If you can't predict what the number making up the sum are, how can you predict the result of their sum? So, the result of the sum is a random number, and the numbers making up the sum are random numbers. For a mathematician, the height of a population would be called a random variable , because height among people making up this population varies randomly.

We generally denote random variables with upper case letters. The letter X is commonly used. If we call X this random variable the population height , we can express the concept of approximating the average adult population height from a sample with the following pseudo-mathematical formula:. This in essence, is what we call a Monte Carlo approximation.

It consists of approximating some property of a very large number of things, by averaging the value of that property for N of these things chosen randomly among all the others. You can also say that Monte Carlo approximation, is in fact a method for approximating things using samples. What we will learn in the next chapters, is that the things which need approximating are called in mathematics expectations more on this soon. As mentioned before the height of the adult population of a given country can be seen as a random variable X. However note that its average value which you get by averaging all the height for example of each person making up the population, where each one of these numbers is also a random number is unique to avoid the confusion with the sample size which is usually denoted with the letter N, we will use M to denote the size of the entire population :.

• Introduction?
• Monte Carlo theory, methods and examples.

In statistics, the average of the random variable X is called an expectation and is written E X. To summarize, Monte Carlo approximation which is one of the MC methods is a technique to approximate the expectation of random variables, using samples. It can be defined mathematically with the following formula:. If you are just interested in understanding what's hiding behind this mysterious term Monte Carlo, then this all you may want to know about it. However for this quick introduction to be complete, let's explain why this method is useful.

It happens as suggested before that computing E X is sometimes intractable.

mod04lec16-Monte Carlo Simulation Introduction - Part 01

This means that you can't compute E X exactly at least not in an efficient way. This is particularly true when very large "populations" are concerned in the computation of E X such as with the case of computing the average height of the adult population of a country. MC approximation offers in this case a very simple and quick way to at least approximate this expectation. It won't give you the exact value, but it might be close enough at a fraction of the cost of what it might take to compute E X exactly, if or possible at all.

To conclude this quick introduction, we realize that many of you have heard the term Monte Carlo ray tracing as well as the term of biased and unbiased ray tracing and probably looked at this page, hoping to find an explanation to what these terms mean. Let's quickly do it, even though we do recommend that you read the rest of this lesson as well as the following ones, to really get in-depth answers to these questions. Figure 1: each pixel of an image is actually a small surface. The color of the surface of the object that it sees varies across its area. Imagine you want to take a picture with a digital camera.

If you divide the surface of your images into a regular grid our pixels , note that each pixel can actually be seen as small but nonetheless continuous surfaces on which light reflected by objects in the scene falls onto. This light will eventually get converted to a single color and we will talk about this process in a moment however if you look through any of these pixels, you might notice that it actually sees more than one objects, or that the color of the surface of the object that it sees, varies across the pixel's area.

Barium titanate is known to exhibit three structural phase transitions, all of which are successfully reproduced using the aforementioned set of algorithms see Fig. However, the results presented in Fig. Such differences can be attributed to the first order character of the phase transitions resulting in the temperature hysteresis. Indeed, the discrepancy of transition temperatures estimates obtained from cooling down and heating up cycles are well-expected in MD simulations since the relaxation time of metastable states can extend beyond the time scale reachable by MD algorithms.

Therefore, it is expected that the transition temperature estimate would depend on the cooling rate, or equivalently on the number of MD steps performed at each temperature. Similarly, although the memory effects for MC sampling are less pronounced, the transition temperature would still depend on the number of sweeps performed at each temperature. In fact, the hysteresis width shall necessarily grow when decreasing the simulation-to-autocorrelation time ratio. Panels g — i of Fig. As it can be readily seen, in the vicinity of the phase transitions, the HMC scheme yields lower sample correlations than the MMC algorithm.

Therefore, at a fixed number of sweeps, the HMC scheme should yield higher accuracy estimates of phase transition temperatures. Similar arguments hold for relative performance of MD and HMC algorithms, thus allowing us to explain the observed mismatch of estimated transition temperature values. At each temperature, 40, HMC MMC sweeps were performed, out of which the first 10, were considered as thermalization sweeps and the thermodynamic averages were computed over the remaining 30, sweeps.

In MD simulations, we have 0. The sequence of structural phase transitions corresponding transition temperatures are indicated by dashed lines is successfully reproduced by all algorithms.

### Recommended Posts:

However, HMC scheme yields higher accuracy of thermodynamic averages as can be seen from g — i that show temperature evolution of autocorrelation times of polarization components obtained for HMC, MMC and MD simulations respectively. Note that while the autocorrelation time in g , h is in the units of MC sweeps, for i the autocorrelation time units are 10 3 MD steps. The initial state of the system is taken to be a supercell divided into two domains of equal volume and opposite orientations of polarization.

For the thermalized MD, we assume that a sweep is finalized after 50 molecular dynamics steps are performed. The plot of potential energy values versus the polarization magnitude at each HMC sweep is shown in d. The bi-domain state taken as the initial configuration is in fact unstable and we expect all the algorithms to converge to the equilibrium monodomain configuration.

Panel b of Fig. It can be readily seen panel b of Fig. Furthermore, we find that the MD scheme is unable to converge within sweeps , MD steps or 2. Panel c shows the evolution with sweeps of the potential energy of the system obtained using HMC algorithm. During the first hundreds of sweeps, the evolution of the state can be described as the motion of the wall along its normal. At this stage, despite the growing polarization, the potential energy does not significantly change. Plotting the values of potential energy at each HMC sweep with respect to the polarization see panel d of Fig.

In section 3 we provide arguments explaining higher performance of HMC scheme for such types of energy profiles. S1 of supplemental material. Naturally, the increased relaxation time can be explained by a significantly larger distance in the configuration space between bi-domain initial and the monodomain states.

In order to achieve high computational performance of the HMC algorithm implementation for effective Hamiltonian simulations, we have employed the approach described in Refs. Such an approach allows for separate diagonalization of all parts of the Hamiltonian and results in O NlogN computational complexity. Such methodology proves useful for MD algorithms too, since it allows for efficient computation of the long-range dipolar forces at all lattice sites once the update of all lattice fields has been performed.

In other words, it is the sequential nature of MMC steps that represents a significant performance bottleneck. The performance difference is all the more pronounced since in constrast to Ref. Performance of the GPU-oriented implementation of the effective Hamiltonian model.

It can be readily noticed that the HMC scheme is more advantageous than the Metropolis algorithm since, theoretically, in the former, all generated trial states should be accepted irrespectively of the length of the trial trajectory. This follows from the total energy conservation property of Hamiltonian dynamics employed in HMC. In contrast, increasing the acceptance ratio within an MMC simulation comes at the cost of constraining the magnitude of random variations introduced to individual degrees of freedom during each MMC step. In other words, an attempt to reduce the amount of redundant states within the MMC chain by increasing the acceptance ratio ineluctably leads to an increase of redundancy due to generation of states that are very close to each other.

In contrast, the HMC algorithm removes such a trade off scenario—the autocorrelation time can be decreased by simply increasing the trial trajectory length while conserving the acceptance ratio at its maximum.

• A Foreword about Monte Carlo!
• Comparison of two Methods of Global Illumination Analysis.
• Ultra Low Power Transceiver for Wireless Body Area Networks.
• Introduction?
• Introduction?
• Introduction to Monte Carlo algorithms!

Note that in practice when the numerical integration is used to estimate trial Hamiltonian trajectories, the total energy conservation can be only approximately achieved and it is very important to opt for symplectic integration schemes 6 to avoid the energy drift problems See supplemental material for more information.

The generated sequences of 10 3 equilibrium states shown as blue dots for the model potential a are presented in e , g , while generated states for potential c are shown in f , h. As can be readily seen, the chosen model potentials have different topologies and therefore can be used to test sampling efficiency in qualitatively different model situations. Panels e and f of Fig. A superior efficiency of HMC sampling is evident for both test cases. The metastable states become more reachable due to high acceptance ratio accessible at longer separations between initial and trail states, which in fact allows to explain better performance of HMC as compared to MMC algorithm in the BaTiO 3 annealing test.

An interesting feature of the HMC scheme that can be revealed in the test involving the Mexcian-hat potential is the ability of the algorithm to efficiently sample energy plateaux and shallow valleys. Within the HMC scheme, generating a random initial momentum tangential or close-to-tangential to the energy isolines will generate a quasi-circular trial trajectory that progresses along the brim.

In contrast, sampling shallow valleys can be rather challenging for MMC and thermalized MD algorithms since on flat energy profiles, both schemes generate motion through the configuration space equivalent to a random walk. Panels a and b of Fig. For the Mexican-hat example, the positive and negative values of the projection of such random force on the curvilinear axis aligned with potential energy minimum isoline would be equiprobable.

Therefore, since the value of the random force changes at each MD step the propagation along the brim of the hat would have only diffusive character. In contrast, in case of the HMC sampling, the random shuffling of momenta does not happen at each Hamiltonian dynamics step but rather at the beginning of each HMC sweep which allows the system to propagate much further along the potential energy isoline.

Trial states that would have been rejected and accepted are indicated with red and blue dots, respectively. The initial state is indicated by a yellow dot. The argument discussed above allows to easily understand the superior efficiency of the HMC scheme, not only in the case of the described toy-model example see panels g and e of Fig.

For example, the rotation of the domain wall under periodic boundary conditions necessarily creates additional boundaries between the two domains. A schematization of such energy landscape is presented in Fig. It is equally important to note the trade offs that come along with the described advantages of the HMC scheme. Firstly, in terms of simplicity of implementation, the MMC scheme remains unmatched since an HMC code, especially its parallel implementation, requires much more effort to develop and debug.

Moreover, parallelization strategies used in this study are not as efficient for problems involving small number of degrees of freedom N of the order of 10 4 or less and can be very challenging to optimize for systems with only short-range interactions. Therefore, in some situations it might be more practical to resort to implementation of Metropolis algorithm even though the number of sweeps required to achieve the same accuracy as with HMC simulation might be higher.

The condition for the current Bragg-Gray approach, i. This means that the Bragg-Gray assumptions used so far break down. For MC calculations simulating ionization chambers, Sempau et al. Note that for conventional field sizes i. It can then be concluded that solving the fluence-based cavity integrals always assumed to be under CPE , discussed in the Background section, is no longer needed for practical dosimetry. In addition, it can also be stated that the assumption of small and independent p det, i should no longer be needed in dosimetry.

The procedure in Eq. It differs from that used by other authors e. Detailed fluence spectra and subsequent perturbation-correction calculations will, however, continue to be useful for analysing the influence of different components in the design of detectors or for pedagogic purposes. For this purpose, electron fluence inside detectors where the composition of certain components can be varied see, e. Since the s, a number of fruitful MC developments have been made for the direct calculation of dose distributions within a patient using linacs phase-space data impinging on 3-D CT images.

There were some early developments see, e. At this point it is interesting to recall that the simulation of accelerator treatment heads was pioneered by the work of Petti et al. Currently, the EGSnrc -based BEAM user code [ 40 ] is probably the most widely used piece of software for this purpose; it was developed within a major project called OMEGA , designed for treatment planning purposes [ 41 , 42 ]. The latter is rather unique in the sense of being a comprehensive system that includes in a single package the simulation of linacs and patient dose-planning calculations plus a number of beam analysing graphical tools.

Since its early development, MCTP is generally based on three calculation steps: i determination of the phase-space data after the primary set of linac collimators, which is a machine but not patient-specific calculation; ii phase-space data after the secondary or multileaf collimators, which define the radiation field for a given treatment; and iii simulation of the patient-specific CT geometry where the dose-planning distribution is computed. S1 determines phase-space data after the primary linac collimators, S2 computes phase-space data after the secondary or multileaf collimators defining the radiation field, and S3 calculates the dose distribution for the patient-specific CT geometry.

In favour of the use of MCTP it could be argued that while most analytical-based algorithms for treatment planning are adequate for calculations in homogeneous media, they have been shown to be rather crude approximations whenever inhomogeneities are present.

Additionally, cost-free MC packages and sufficient computer power are available today at most desks. Unfortunately, for sake of speed, some of the commercial MCTPs are based on MC codes trimmed for low-Z media , limiting for instance the number of materials they can handle i. On the question about calculating dose-to-tissue or dose-to-water, different arguments have been provided in the literature:. D w is the basis for current clinical experience and trials, meaning that compliance with experience, mainly developed with conventional TPSs, and with established criteria for therapeutic and normal-tissue tolerance, is required.

The calibration of radiotherapy beams is always made in terms of the reference absorbed dose to water, which is used for any TPS dose normalization. Converting between D tis and D w introduces additional uncertainty in the treatment planning process, but a relation between D tis and D w is still necessary because of the normalization to the beam calibration reference dose to water. With regard to the inherently exact characterof MCTP calculations one could argue that, in addition to the sometimes over-simplified physical models implemented in certain MCTP systems, all existing methods for tissue segmentation, where densities are obtained from CT data, and used on a look-up table to assign different tissue types, neglect patient-to-patient variation of tissue compositions, and assume that these are patient-independent they use ICRU or ICRP compositions.

Obtaining this I -value requires the detailed atomic composition of the medium electron distributions per shell for a theoretical calculation, or an experimental determination using measurements with heavy-charged particles, an approach unrealistic to accomplish for individual body tissues as is done, for instance, for some compounds. Furthermore, even if tissue compositions were known, for example through MR-spectroscopy, the usual Bragg-additivity rule is a crude approximation that ignores aggregate effects, justifying the large uncertainties estimated for body-tissues stopping powers.

Calculations reported in ref. The differences, shown for a change in I adipose from The differences are clearly higher at low electron energies but, as is shown in Fig. The answer to the inherently exact character of MCTP calculations is therefore negative. Generic I -values represent a major limitation on any MTCP and even on full MC systems , as individual body-tissue stopping powers are required.

Hence, this issue questions the claimed low-uncertainty of MCTP, even if the method is still superior to that of analytical algorithms. The remaining important issue is the conversion between D tis and D w , applicable to MCTP or to any other type of TPS, to relate a calculated D tis to the reference dose to water obtained at beam calibration.

The ratio between the two absorbed doses can be written as:.

## Monte Carlo simulations in radiotherapy dosimetry | Radiation Oncology | Full Text

This equation should not be confused with a Bragg-Gray stopping-power ratio, see Eq. Equation 13 points at that the widely used conversion of Siebers et al. To illustrate this statement, one can be write. This is a conclusion that parallels the well-known expression for reference dosimetry given in Eq.

The fluence correction factor, written as. Similar calculations to those described for high-energy photons have been done in ref. The use of the Monte Carlo method for calculations in radiotherapy dosimetry has become the most efficient and consistent tool for simulations in most of the fields related to the speciality, from basic dosimetric quantities, like stopping-power ratios and perturbation correction factors for reference ionization chamber dosimetry, to fully realistic simulations of clinical accelerators, detectors and patient treatment planning.

Its accurate use requires consistency in the data throughout the entire dosimetry chain, and the recent updates of key dosimetric data by ICRU Report 90 are necessary in reference dosimetry. Although data consistency is probably less critical for treatment planning, their implementation also in this field is advised. There are, however, a number of other issues raised throughout this work to conclude with the recommendation that no MC calculation should be considered free of errors.

## A Beginner's Guide to Markov Chain Monte Carlo, Machine Learning & Markov Blankets

Recall that, strictly speaking, the quantity absorbed dose cannot be measured ; it is always determined from measurements of related quantities, like charge, current, heat, chemical changes, etc. It should be noted that ICRU Report 85 [ 4 ] included an incomplete definition of the quantity restricted cema, which did not consider the track-end term; this definition was, however, updated in ICRU Report 90 [ 5 ].

Andreo P. Monte Carlo techniques in Medical Radiation Physics. Phys Med Biol.

• The Essential Writings of Ralph Waldo Emerson (Modern Library Classics)!
• Kubricks total cinema : philosophical themes and formal qualities!
• Submission history.
• Randomized Algorithms | Set 2 (Classification and Applications)?
• Lecture 1: Introduction to Monte Carlo algorithms!

Bielajew A. Monte Carlo Techniques in Radiation Therapy. Fundamentals of Ionizing Radiation Dosimetry. Weinheim: Wiley-VCH; Consistency in reference radiotherapy dosimetry: resolution of an apparent conundrum when 60 Co is the reference quality for charged-particle and photon beams. Andreo P, Benmakhlouf H.

Role of the density, density effect and mean excitation energy in solid-state detectors for small photon fields. Vienna: International Atomic Energy Agency; Berger MJ. Methods in Computational Physics. New York: Academic Press: Salvat F. Ottawa: National Research Council Canada; Calculation of energy and charge deposition and of the electron flux in a water medium bombarded with 20 MeV electrons.

Ann N Y Acad Sci. Stopping-power ratios for electron dosimetry with ionization chambers. Vienna: International Atomic Energy Agency: Nahum AE. Andreo P, Brahme A. Stopping power data for high-energy photon beams. Med Phys.