1 Everyday Statistics in Monte Carlo Shielding Calculations One Key Statistics: ERROR, and why it...

34
1 Everyday Statistics in Everyday Statistics in Monte Carlo Shielding Monte Carlo Shielding Calculations Calculations One Key Statistics: ERROR, and One Key Statistics: ERROR, and why it can’t tell the whole why it can’t tell the whole story story Biased Sampling vs. Random Biased Sampling vs. Random Sampling Sampling

Transcript of 1 Everyday Statistics in Monte Carlo Shielding Calculations One Key Statistics: ERROR, and why it...

Page 1: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

11

Everyday Statistics in Monte Everyday Statistics in Monte Carlo Shielding CalculationsCarlo Shielding Calculations

One Key Statistics: ERROR, and why One Key Statistics: ERROR, and why it can’t tell the whole storyit can’t tell the whole story

Biased Sampling vs. Random Biased Sampling vs. Random SamplingSampling

Page 2: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

22

What is a Monte Carlo What is a Monte Carlo Calculation?Calculation?

Monte Carlo methodsMonte Carlo methods are a class are a class of computational algorithms that rely of computational algorithms that rely on repeated random sampling to on repeated random sampling to compute their results. compute their results.

Page 3: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

33

WarningWarning

Monte Carlo Statistics will help us with answer how precisely we answered our question, but not how accurate our model is.

Page 4: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

44

Bottom Line in an MCNP Bottom Line in an MCNP outputoutput

tally 2tally 2 nps mean error vov slope fomnps mean error vov slope fom 512000 9.7768E-04 0.0010 0.0002 1.5 519843512000 9.7768E-04 0.0010 0.0002 1.5 519843

nps = number of starting particles runnps = number of starting particles run

mean = result of the tallymean = result of the tally

error = standard deviation / meanerror = standard deviation / mean

vov = variance of the variancevov = variance of the variance

slope = slope = Pareto slope of the history score probability density function

fom = figure of merit

Page 5: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

55

MCNP DetailsMCNP Details

MCNP = Monte Carlo N-Particle Code, MCNP = Monte Carlo N-Particle Code, developed at Los Alamos National developed at Los Alamos National Laboratory since the 1940’sLaboratory since the 1940’s

Actual MCNP outputs contain a lot of Actual MCNP outputs contain a lot of detailed data.detailed data.

Page 6: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

66

Example Monte Carlo (Not Example Monte Carlo (Not MCNP) RunMCNP) Run

Sampling photons from Am-241 Sampling photons from Am-241

There are 153 photonsThere are 153 photons

Sample strategy – random number Sample strategy – random number from 1 to 153 identifies the photonfrom 1 to 153 identifies the photon

A weighting factor (a very important A weighting factor (a very important statistic) is used to adjust for statistic) is used to adjust for probabilities of these photons, the probabilities of these photons, the lowest at 5.5E-10.lowest at 5.5E-10.

Page 7: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

77

Example Monte Carlo (Not Example Monte Carlo (Not MCNP) RunMCNP) Run

This is biased sampling because each This is biased sampling because each photon is sampled uniformly, without photon is sampled uniformly, without regard to its probability.regard to its probability.

Page 8: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

88

Am-241 Spectum

1.E-10

1.E-09

1.E-08

1.E-07

1.E-06

1.E-05

1.E-04

1.E-03

1.E-02

1.E-01

1.E+00

0 0.2 0.4 0.6 0.8 1 1.2

MeV

Inten

sity

Page 9: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

99

Example PseudocodeExample Pseudocode

Assign a starting value for “dose.”Assign a starting value for “dose.”

Start a loop.Start a loop.

Select a random integer from 1 to 153.Select a random integer from 1 to 153.

Use the random number to select one of the Use the random number to select one of the photons.photons.

Multiply the photon by its weight. Multiply the photon by its weight.

Add this sum to: Add this sum to:

current dose estimate * number of previous runs. current dose estimate * number of previous runs.

Divide this by the number of current runs. Divide this by the number of current runs.

End loopEnd loop

Page 10: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1010

MCNP includes a lot of operations, such MCNP includes a lot of operations, such as:as:

Start a source particle (energy, direction);

Find the distance to the next boundary, cross the surface and enter the next cell;

Find the total photon cross section and process photon collisions producing electrons as appropriate;

Follow electron tracks; Process tallies.

Page 11: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1111

In our demo, we are only going to:In our demo, we are only going to: Start a source particle.

Process tallies.

Page 12: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1212

Example RunExample Run

-> Switch to live R presentation <--> Switch to live R presentation <-

The following slides are samples of the The following slides are samples of the live presentation.live presentation.

Page 13: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1313

First 200 photonsFirst 200 photons

Page 14: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1414

Page 15: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1515

Page 16: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1616

Page 17: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1717

Up to 400Up to 400

Page 18: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1818

Page 19: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

1919

Page 20: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2020

Up to 10,000Up to 10,000

Page 21: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2121

Page 22: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2222

In a well-behaved Monte In a well-behaved Monte Carlo run, expect the error Carlo run, expect the error to decrease as the square to decrease as the square of the number of samples of the number of samples increases. For example to increases. For example to divide error by 2, multiply divide error by 2, multiply

samples by 4.samples by 4.

Page 23: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2323

<End of Live Section><End of Live Section>

Page 24: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2424

nps Dose

MC Erro

r vov|Error| from

True

200 0.0252 0.2405 0.0120 0.2267

400 0.0244 0.2663 0.0132 0.2510

1,000 0.0229 0.2144 0.0068 0.2975

10,000 0.0336 0.1335 0.0013 0.0319

100,000 0.0333 0.0534 0.0001 0.0218

799,485

0.032579 n/a n/a 0.0004

Page 25: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2525

Time to Evaluate the Sampling Time to Evaluate the Sampling BiasBias

Did it help or hurt our statistics to Did it help or hurt our statistics to bias the sampling?bias the sampling?

In the slides that follow, we compare In the slides that follow, we compare unbiased sampling to biased unbiased sampling to biased sampling for two cases.sampling for two cases.

Page 26: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2626

Comparison to an MCNP runComparison to an MCNP run

Simple Model: Simple Model: point source in point source in vacuum.vacuum.

Tally at a sphere in Tally at a sphere in vacuum.vacuum.

This is very much This is very much like our R model.like our R model.

Later, we add a Later, we add a twist: a steel twist: a steel shield.shield.

Page 27: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2727

Mean

2.85E-02

2.90E-022.95E-02

3.00E-02

3.05E-023.10E-02

3.15E-02

3.20E-02

3.25E-023.30E-02

3.35E-02

10000 100000 1000000 10000000

"random sampling" "uniform sampling"

Page 28: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2828

Error

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0.1

10000 100000 1000000 10000000

random sampling uniform sampling

Page 29: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

2929

For the Simple Case…For the Simple Case…

The random sample looks good. All The random sample looks good. All statistical checks were passed.statistical checks were passed.

But if you look at the output in detail…But if you look at the output in detail… Many of the low probability particles Many of the low probability particles

were not sampled at all.were not sampled at all. We ran 10,000,000 particles, but that We ran 10,000,000 particles, but that

wasn’t enough to ensure we sampled wasn’t enough to ensure we sampled all the particles. all the particles.

Page 30: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

3030

Now Add ½” SteelNow Add ½” Steel

Page 31: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

3131

Mean

0.00E+00

2.00E-06

4.00E-06

6.00E-06

8.00E-06

1.00E-05

1.20E-05

1.00E+04 1.00E+05 1.00E+06 1.00E+07

"Random Sampling" "Uniform Sampling"

Page 32: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

3232

Error

0

0.2

0.4

0.6

0.8

1

1.2

1.00E+04 1.00E+05 1.00E+06 1.00E+07

"Random Sampling" "Uniform Sampling"

Page 33: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

3333

Summary StatisticsSummary Statistics

BiasedBiased

Mean error vov slope fomMean error vov slope fom9.97E-06 0.0028 0.0001 10 37689.97E-06 0.0028 0.0001 10 3768

UnbiasedUnbiased

Mean error vov slope fomMean error vov slope fom9.92E-06 0.053 0.0079 10 129.92E-06 0.053 0.0079 10 12

Page 34: 1 Everyday Statistics in Monte Carlo Shielding Calculations  One Key Statistics: ERROR, and why it can’t tell the whole story  Biased Sampling vs. Random.

3434

ConclusionsConclusions

How you sample makes a difference. How you sample makes a difference. But it depends on the problem what But it depends on the problem what the preferred sampling will be.the preferred sampling will be.

MCNP Summary Statistics are a MCNP Summary Statistics are a helpful guide, but they do not tell the helpful guide, but they do not tell the whole story.whole story.