0% found this document useful (0 votes)
3 views18 pages

Lectures 18-19

The document discusses Monte Carlo methods, which are statistical sampling techniques used in various applications such as evaluating integrals, predicting stock values, and solving differential equations. It explains the Monte Carlo simulation process, the importance of random number generation, and techniques for variance reduction. Additionally, it covers specific algorithms like Metropolis Monte Carlo and simulated annealing, highlighting their relevance in computational biophysics.

Uploaded by

azhagar_ss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views18 pages

Lectures 18-19

The document discusses Monte Carlo methods, which are statistical sampling techniques used in various applications such as evaluating integrals, predicting stock values, and solving differential equations. It explains the Monte Carlo simulation process, the importance of random number generation, and techniques for variance reduction. Additionally, it covers specific algorithms like Metropolis Monte Carlo and simulated annealing, highlighting their relevance in computational biophysics.

Uploaded by

azhagar_ss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Computational Biophysics@CSE, IITKGP Spring 2018

Lecture 18-19

Monte Carlo Simulations

Monte Carlo Methods


• Monte Carlo is another name for statistical sampling
methods of great importance to physics and computer
science
• Applications of Monte Carlo Method
– Evaluating integrals of arbitrary functions of 6+
dimensions
– Predicting future values of stocks
– Solving partial differential equations
– Sharpening satellite images
– Modeling cell populations
– Finding approximate solutions to NP-hard problems

[email protected] 1
Computational Biophysics@CSE, IITKGP Spring 2018

What is Monte Carlo (MC) method ?


The Monte Carlo method is a numerical method
for statistical simulation which utilizes sequences
of random numbers to perform the simulation

What the meaning of MC


simulation?

MC simulation is a versatile tool to analyse


and evaluate complex measurements

Constructing a model of a system.

Experimenting with the model to draw inferences of the


system’s behavior

[email protected] 2
Computational Biophysics@CSE, IITKGP Spring 2018

A simulation model

Inputs outputs
Measures of
Decision and
Simulation performance or
uncontrollable
model behaviour of the
variables
system

A simulation model cont..

• Model inputs capture the environment of the problem


• The simulation model
– Conceptual model: set of assumptions that define
the system
– Computer code: the implementation of the
conceptual model
• Outputs describe the aspects of system behaviour that
we are interested in

[email protected] 3
Computational Biophysics@CSE, IITKGP Spring 2018

Random numbers

Uniform Random numbers or pseudo-random numbers (PRN)


are essentially independent random variables uniformly
Distributed over the unit interval (0,1).

The PRNs are good if they are uniformly distributed,


statistically independent and reproducible.

Classic Example

Find the value of 


Use the reject and accept method
Or hit and miss method

The area of square=(2r)²

The area of circle = r² 


area  of  square 4r 4 2

 
area  of  circle r  2

area  of  circle
  4*
area  of  square

[email protected] 4
Computational Biophysics@CSE, IITKGP Spring 2018

Cont..
area.of .circle .. #.of .dots.inside.circle

area.of .square total.number.of .dots
Hit and miss algorithm
 Generate two sequences of N of PRN :: Ri,,Rj
 Xi=-1+2Ri
 Yj=-1+2Rj
 Start from s=zero
 If (X²+Y²<1) s=s+1

 # of dots inside circle=s


 total number of dots=N

  4* S / N

Solving Integration Problems via Statistical Sampling:


Monte Carlo Approximation
• How to evaluate integral of f(x)?

[email protected] 5
Computational Biophysics@CSE, IITKGP Spring 2018

Integration Approximation
• Can approximate using another function g(x)

Integration Approximation
• Can approximate by taking the average or expected value

[email protected] 6
Computational Biophysics@CSE, IITKGP Spring 2018

Integration Approximation
• Estimate the average by taking N samples

Monte Carlo Integration

• Im = Monte Carlo estimate


• N = number of samples
• x1, x2, …, xN are uniformly distributed random numbers between a
and b

[email protected] 7
Computational Biophysics@CSE, IITKGP Spring 2018

Monte Carlo Integration

Variance
• The variance describes how much the sampled values vary from
each other.

 Variance proportional to 1/N

[email protected] 8
Computational Biophysics@CSE, IITKGP Spring 2018

Variance
• Standard Deviation is just the square root of the variance
• Standard Deviation proportional to 1 / sqrt(N)

• Need 4X samples to halve the error

Variance
• Problem:
– Variance (noise) decreases slowly
– Using more samples only removes a small amount of noise

[email protected] 9
Computational Biophysics@CSE, IITKGP Spring 2018

Variance Reduction
• There are several ways to reduce the variance
– Importance Sampling
– Stratified Sampling
– Quasi-random Sampling
– Metropolis Random Mutations

Importance Sampling
 Idea: use more samples in important regions of the function
 If function is high in small areas, use more samples there

[email protected] 10
Computational Biophysics@CSE, IITKGP Spring 2018

Importance Sampling

• Want g/p to have low variance


• Choose a good function p similar to g:

Stratified Sampling
• Partition S into smaller domains Si
• Evaluate integral as sum of integrals over Si
• Example: jittering for pixel sampling
• Often works much better than importance sampling in practice

[email protected] 11
Computational Biophysics@CSE, IITKGP Spring 2018

Random versus Pseudo-random


• Virtually all computers have “random number”
generators
• Their operation is deterministic
• Sequences are predictable
• More accurately called “pseudo-random number”
generators
• In this chapter “random” is shorthand for “pseudo-
random”
• “RNG” means “random number generator”

Properties of an Ideal RNG


• Uniformly distributed
• Uncorrelated
• Never cycles
• Satisfies any statistical test for randomness
• Reproducible
• Machine-independent
• Changing “seed” value changes sequence
• Easily split into independent subsequences
• Fast
• Limited memory requirements

[email protected] 12
Computational Biophysics@CSE, IITKGP Spring 2018

No RNG Is Ideal
• Finite precision arithmetic  finite number of
states  cycles
– Period = length of cycle
– If period > number of values needed, effectively
acyclic
• Reproducible  correlations
• Often speed versus quality trade-offs

Linear Congruential RNGs

X i  (a  X i 1  c) mod M

Modulus

Additive constant
Multiplier

Sequence depends on choice of seed, X0

[email protected] 13
Computational Biophysics@CSE, IITKGP Spring 2018

Period of Linear Congruential RNG


• Maximum period is M
• For 32-bit integers maximum period is 232, or
about 4 billion
• This is too small for modern computers
• Use a generator with at least 48 bits of
precision

Producing Floating-Point Numbers


• Xi, a, c, and M are all integers
• Xis range in value from 0 to M-1
• To produce floating-point numbers in range [0,
1), divide Xi by M

[email protected] 14
Computational Biophysics@CSE, IITKGP Spring 2018

Defects of Linear Congruential RNGs

• Least significant bits correlated


– Especially when M is a power of 2
• k-tuples of random numbers form a lattice
– Points tend to lie on hyperplanes
– Especially pronounced when k is large

Lagged Fibonacci RNGs

X i  X i  p  X i q

 p and q are lags, p > q


 * is any binary arithmetic operation
 Addition modulo M
 Subtraction modulo M
 Multiplication modulo M
 Bitwise exclusive or

[email protected] 15
Computational Biophysics@CSE, IITKGP Spring 2018

Properties of Lagged Fibonacci RNGs

• Require p seed values


• Careful selection of seed values, p, and q can
result in very long periods and good
randomness
• For example, suppose M has b bits
• Maximum period for additive lagged Fibonacci
RNG is (2p -1)2b-1

Types of distribution

Uniform distribution Gaussian or normal distribution

[email protected] 16
Computational Biophysics@CSE, IITKGP Spring 2018

Metropolis Monte Carlo

Replica Exchange Monte Carlo

Parallelism in Monte Carlo Methods


• Monte Carlo methods often amenable to
parallelism
• Find an estimate about p times faster
OR
• Reduce error of estimate by p1/2

[email protected] 17
Computational Biophysics@CSE, IITKGP Spring 2018

Simulated Annealing
• Simulated annealing.
– T large  probability of accepting an uphill move is large.
– T small  uphill moves are almost never accepted.
– Idea: turn knob to control T.
– Cooling schedule: T = T(i) at iteration i.

• Physical analog.
– Take solid and raise it to high temperature, we do not expect it to
maintain a nice crystal structure.
– Take a molten solid and freeze it very abruptly, we do not expect to
get a perfect crystal either.
– Annealing: cool material gradually from high temperature, allowing it
to reach equilibrium at succession of intermediate lower
temperatures.

[email protected] 18

You might also like