Lectures 18-19
Lectures 18-19
Lecture 18-19
[email protected] 1
Computational Biophysics@CSE, IITKGP Spring 2018
[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
[email protected] 3
Computational Biophysics@CSE, IITKGP Spring 2018
Random numbers
Classic Example
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
4* S / N
[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
[email protected] 7
Computational Biophysics@CSE, IITKGP Spring 2018
Variance
• The variance describes how much the sampled values vary from
each other.
[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)
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
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
[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
X i (a X i 1 c) mod M
Modulus
Additive constant
Multiplier
[email protected] 13
Computational Biophysics@CSE, IITKGP Spring 2018
[email protected] 14
Computational Biophysics@CSE, IITKGP Spring 2018
X i X i p X i q
[email protected] 15
Computational Biophysics@CSE, IITKGP Spring 2018
Types of distribution
[email protected] 16
Computational Biophysics@CSE, IITKGP Spring 2018
[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.