Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Monte Carlo Analysis in Excel

A Design Tool For The Component Engineer


Chuck Johnson
24 January 2014
Engineering Tolerances
“Tolerance has many meanings, ranging from purchase tolerance (initial tolerance) to end-of-life
tolerance (total error budget). The last thing you need to know in the component selection process is the
part's initial tolerance. The first thing you need to know is the required end-of-life tolerance of the design.
You need to evaluate all the components for their expected changes after all of the stresses and exposures
they might experience over the planned life of the equipment.” (EDN – 11/19/13)

Design and Component engineers select components for a particular design based on their
understanding of the requirements applicable to the design. In the best of worlds, these engineers would
have been involved in something called, arbitrarily, Requirements Flowdown. Requirements Flowdown is a
process that takes a set of Top Level Requirements for an End Item (Product) and devolves (decomposes)
them down to the lowest levels of assembly. Design Specifications usually specify limits on Input and
Output parameters using terms like Minimum and Maximum for the design. They rarely specify
the parameter distributions. So, the Design/Component engineer usually works with Minimum and
Maximum values which establish a range of values within which the design must operate.

Three common tolerance analysis methods are:


1. Worst Case1
2. Root Sum of Squares (RSS)1
3. Statistical

Worst Case design analysis allows each component to be at its minimum or maximum value and
then, based on the interaction of the individual components, computes the minimum and maximum
expected performance values.

Root Sum of Squares analysis uses the square root of the sum of the individual component
tolerances squared.

Monte Carlo (Statistical) analysis uses theoretical or actual component population distributions.

In examining any design to determine component level parameter requirements/tolerances with final
cost being the independent variable we might perform a “tradeoff” study of looser tolerances and resulting
scrap rate versus tighter tolerances and resulting scrap rate. Monte Carlo analysis is a good tool for this
“tradeoff” study.

Monte Carlo Analysis


Monte Carlo analysis is a method that uses randomly selected data from a set of known/theoretical
distributions to predict the performance of a system constructed from the set of known/theoretical
distributions; wherein the system output can be mathematically described.

A system analysis based on the Monte Carlo method can be performed a priori (before the system is
built) or a posteriori (after the system is built). A priori Monte Carlo analyses are useful in predicting system
performance based on assumed population distributions. A posteriori Monte Carlo analyses are useful in
confirming/disproving the conclusions derived from the a priori analyses.

An electrical circuit comprised of components whose value distributions are known (empirically,
experimentally, theoretically) with an output that can be mathematically described can be modeled and,
using the Monte Carlo method, have its performance predicted.

1 http://adcats.et.byu.edu/Publication/03-1/BasicTools1.pdf

2
The Monte Carlo method operates as follows:
1. Component distributions (populations) are quantified.
2. A system output equation is defined.
3. A randomization technique is selected.
4. A program is written that iteratively and randomly pulls samples from each population.
5. The program output is recorded for a preselected number of trials.
6. The distribution of the trial results is then statistically analyzed.

The Monte Carlo analysis results are completely dependent on population distribution assumptions.
Some commonly used distributions are:

1. Normal – The population is described by Mean and Standard Deviation and is commonly
referred to as the “bell curve”. The population is normally distributed above and below the Mean value.
2. Lognormal – The population is described by Mean and Standard Deviation. The population
is positively skewed.
3. Uniform – The population values have an equal probability of occurrence within lower and
upper limits.
4. Triangular – The population is described by Minimum, Maximum and Most Probable
values.
5. Empirical – A population is described by results taken from inspections or tests of actual
populations.

Note: Empirical Distributions should be examined closely to determine if they contain “outliers”. An outlier is
a value that is well outside the values of other members of a population. Outlier tests exist and should be
used before accepting an empirical data set.

Monte Carlo and Excel


Microsoft Excel can be used to perform Monte Carlo analysis. Excel Add-In packages are available
that provide an array of population distributions and tools to use these population distributions in Monte
Carlo analysis. We used a free Excel Add-In called PopTools2 for our examples.

To illustrate the Monte Carlo technique, we used Tina-TI (free software from Texas Instrument) to
create the circuit models used in our examples and Excel 2003 for the Monte Carlo analysis.

Our Excel Monte Carlo analysis contained 10,000 trials (this number can be increased by either
increasing the number of trials directly or using Excel VBA (Appendix) to iterate the 10,000 trials as many
times as desired).

Excel itself can be used to generate a Monte Carlo analysis by using Excel’s Random Number
Generator (Appendix)

Examples – Some simple illustrations of Monte Carlo analysis follow


Example 1 – Assume that a design specification requires the resistor network shown in Figure 1. The
specification further states that the network value tolerance limits be + 2%. This translates into a Minimum
network resistance value of 419.4 Ω (ohms) and a Maximum network resistance value of 436.6 Ω. We want
to examine some different resistor procurement options:
Option 1 Buy + 5% tolerance resistors and see what our expected yield would be.
Option 2 Buy + 2% tolerance resistors and see what our expected yield would be
Option 3 Buy + 1% tolerance resistors and see what our expected yield would be
Option 4 Selectively assign tighter tolerances to the resistors with the greatest impact on the network
resistance value. Look at the resultant yield.

2 - http://www.poptools.org/
3
Figure 1 – Resistor Network

Rnetwork = R1+R2+R3*R4/(R3+R4)+R5*R6/(R5+R6)+R7

For this example, we assumed normal distributions with the tolerance limit equal to +3σ (99.5% of
the values fell inside the tolerance limits – Figure 2). Table 1 summarizes the results of a typical 10,000
sample trial in the MCResults column. The Specification column shows the desired mean value and the
specification limits. The CountIf column counts the number of samples that were outside the specification
limits. PopTools generated the Figure 2 histogram. Figure 3 shows the results of a 10,000 sample trial using
the PopTools normal distribution with mean and standard deviation specified for each component.

Figure 2 Normal Distribution Curve

Table 1 contains the results of a single 10,000 sample trial run. In this trial, the mean value was
427.92 Ω. The minimum and maximum values were outside the tolerance lower and upper limits. The
columns labeled CountIf (=COUNTIF(H2:H10001,"<" & R4) and (=COUNTIF(H2:H10001,">" & R5) show
the number of samples that were outside the lower and upper specification limits. For this trial run 522
samples were below the lower specification limit and 515 samples were above the upper specification limit.

4
Table 1 Option 1 Results for 5% Resistors
MonteCarloTest MCResults Specification CountIf
Mean 427.92 428
StdDev/Limit 5.29 2.00%
Min 406.06 419.44 522
Max 447.08 436.56 515
Count 10000
Median 427.95
Test value 428.00
Exceed test 4960
Less than test 5040
Lower percentile 417.52 (2.50%)
Upper percentile 438.26 (97.50%)
Bins 25
Bin size 1.71

Figure 3 – Option 1 Results For 5% Resistors Using Pop Tools Random Number Generator
Resistor Network
1400

1200

1000

800

600

400

200

0
410
412
414
415
417
419
420
422
424
426
427
429
431
432
434
436
438
439
441
443
444
446
448
450
451

Table 2 contains the results of each procurement possibility (Options 1 – 4). We wrote a simple VBA
routine (Appendix) that ran ten trials, each with 10,000 samples, and stored the failure results in two arrays.
The array values were then transposed to the appropriate cells in the Excel worksheet.

The least expensive resistor choice (5% for all) gives a final assembly yield (~90%) that might be
worth considering factoring in the scrappage cost. All the other procurement options yield very low
scrappage rates.

5
Table 2 – Monte Carlo Trial Results Summary
Trial# 5% 5% 2% 2% 1% 1% Mix1 Mix1 Mix2 Mix2 Mix3 Mix3
Trial1 533 510 0 1 0 0 6 5 0 0 0 0
Trial2 519 530 1 0 0 0 4 6 0 0 0 0
Trial3 518 569 0 0 0 0 5 1 0 0 0 0
Trial4 510 540 0 1 0 0 4 2 0 0 0 0
Trial5 555 504 0 1 0 0 4 2 0 0 0 1
Trial6 535 526 2 0 0 0 5 5 0 0 1 0
Trial7 517 534 2 1 0 0 3 3 0 0 0 0
Trial8 526 510 1 0 0 0 4 4 0 0 0 1
Trial9 498 467 0 0 0 0 3 4 1 0 0 0
Trial10 546 504 0 1 0 0 9 9 0 0 2 1

Fail # 5257 5194 6 5 0 0 47 41 1 2 3 3


Fail % 5.26% 5.19% 0.01% 0.01% 0.00% 0.00% 0.05% 0.04% 0.00% 0.00% 0.00% 0.00%
Mix1 R2 = 2% all other resistors 5%
Mix2 R2 = 1% all other resistors 5%
Mix3 R2 and R3 = 2% all other resistors 5%

Figure 4 Option 1 Results For 5% Resistors Using Excel Random Number Generator
Predicted Distribution Using Excel Random Numbers
1400

1200

1000

800

600

400

200

0
410
411
413
415
417
418
420
422
423
425
427
428
430
432
433
435
437
438
440
442
443
445
447
448
450

Example 2 – The Figure 5 design was actually used in a missile application. The design engineer asked
for a prediction of the expected Analog Time Delay performance at ambient. We modeled the circuit using
Tina-TI and created an Excel workbook with the values shown in Figure 5. We then ran a Monte Carlo
analysis. Table 3 contains the analysis results. The power supply (V1) used a LP2985AIM5-5.0 with an
advertized output tolerance of 1%. This was used in the analysis. Normal distributions were assumed for all
components with the advertized tolerance equated to 3σ.

6
Figure 5 – Analog Time Delay

Rt = R1+R2
Ct = C1+C2+C3
Vin = 5VDC +/- 1%
Rf = R6/(R3+R6)
Vout = Vin*(R5/(R4+R5))*(1/Rf)

Time = -Rt*Ct*ln(Vout/Vin)

Table 3 – Tabular Results Of One 10,000 Sample Monte Carlo Run


MonteCarloTest MCResults Specification CountIf
Mean 10.04 10.00
StdDev/Limit 0.0973614 5.00%
Min 9.68 9.5 0
Max 10.43 10.5 0
Count 10000
Median 10.04
Test value 10
Exceed test 6739
Less than test 3261
Lower percentile 9.8522804 (2.50%)
Upper percentile 10.23532 (97.50%)
Bins 25
Bin size 0.0312876

Table 3 shows the results of a typical 10,000 samples trial in the MCResults column. The
Specification column shows the desired mean value and the specification limits. The CountIf column counts
the number of samples that were outside the specification limits for a typical 10,000 sample run. Pop Tools
generated the Figure 3 histogram.

7
Figure 6 Histogram Of One 10,000 Sample Monte Carlo Run
Analog Timer Distribution
1400

1200

1000

800

600

400

200

0
9.70

9.73
9.76
9.79

9.82
9.85
9.88
9.91

9.94
9.97
10.00

10.03

10.06
10.09
10.12

10.15
10.18

10.21

10.24

10.27
10.30

10.33

10.36
10.39

10.42
Example 3 – This example uses the Figure 1 circuit diagram. In this example, 25 samples of each resistor
are measured at incoming inspection and the values recorded. This is the empirical database.
A Monte Carlo analysis can be performed in Excel that randomly matches components from each
empirical resistor data group to determine the expected resistor network value.
The basic technique used is as follows:

Component Random Excel Monte Carlo


Data Base Number Vlookup Value
Serialized Generator Function

Seven random number generators are required, one for each empirical resistor data base. The
Excel VLOOKUP function is used with each random number generator and each component database to
select the resistor value for each trial. Figure 4 shows the results of a 10,000 sample run wherein the
resistor were randomly selected from each empirical database. We created the empirical database for each
resistor by randomly pulling 25 samples from a normally distributed resistor population. The results are
interesting in that they show the effect of sampling on the resultant population.

8
Figure 7 Histogram Of One 10,000 Sample Monte Carlo Run For Empirical Database
Monte Carlo Results For Empirical Database
900

800

700

600

500

400

300

200

100

0
418.5

419.7

420.9

422.2

423.4

424.6

425.8

427.0

428.2

429.4

430.6

431.8

433.0

434.2

435.4

436.6

437.8

439.0

440.2

441.4

442.6

443.8

445.0

446.2

447.4
Example 4 – This example uses the Figure 1 circuit diagram. In this example, we assumed that the
manufacturer had culled out all 1% and 2% resistor values from the normally distributed 5% population
leaving a bifurcated distribution (resistor values at both the low and high ends of the distribution). “A
resistor's value often is close to its limit when you purchase it, because many manufacturers select and
remove the center of the distribution when grading resistors to sell as their tighter tolerance grades.”
(EDN – 4/15/2004)

We ran a Monte Carlo analysis as described in Example 1 to look at the expected population
distribution. Figure 4 shows the results. The rejects jumped from ~10% to ~50% with 5% resistors.

Figure 8 Resistor Assembly Value Distribution With Bifurcated Resistor Populations


Bifurcated Resistor Distributions
1200

1000

800

600

400

200

0
408.5
410.3
412.2
414.0
415.8
417.6
419.4
421.3
423.1
424.9
426.7
428.5
430.3
432.2
434.0
435.8
437.6
439.4
441.3
443.1
444.9
446.7
448.5
450.3
452.2

9
Appendix
VBA Code – We wrote a small VBA routine that iterated the Monte Carlo test ten times resulting in one
million total trials and then tabulated the results of each Option experiment. The code can be adapted to any
worksheet where the desired cell locations are specified.

Sub CountFailures()
Dim I As Integer
ReDim A(10) ‘Array
ReDim B(10) ‘Array
For I = 1 To 10
Calculate
A(I) = Cells(4, 19) 'Count Lower Limit (LL) failures
B(I) = Cells(5, 19) 'Count Upper Limit (UL) failures
Next I
Cells(26, 13) = Application.Sum(A) 'Total LL failures
Cells(26, 14) = Application.Sum(B) 'Total UL failures
Range(Cells(15, 13), Cells(24, 13)) = WorksheetFunction.Transpose(A) 'Copy Array to worksheet
Range(Cells(15, 14), Cells(24, 14)) = WorksheetFunction.Transpose(B) 'Copy Array to worksheet
End Sub

We modeled the Figure 1 example in two ways:


PopTools implementation from an Excel worksheet

Table 1A shows the resistor values table used in the simulation. Column O has taken the tolerance
specified in Column P and divided it by 3 to arrive at a 3 sigma (σ) standard deviation. The tolerance and
the sigma value can be changed to observe the effect of each on simulation results.

Example 1 Particulars From Excel Worksheet


Table 1A – Resistor Values
M N O P Q R
R1 100 1.67 5% 95 105
R2 300 5.00 5% 285 315
R3 20 0.33 5% 19 21
R4 20 0.33 5% 19 21
R5 40 0.67 5% 38 42
R6 10 0.17 5% 9.5 10.5
R7 10 0.17 5% 9.5 10.5

Table 1B shows the first two rows of the computational part of the spreadsheet.

Table 1B – Simulation Sample Row


A B C D E F G H
R1 R2 R3 R4 R5 R6 R7 RNet
99.17 293.05 19.53 20.25 40.24 10.07 9.93 420.15

Pop Tools Implementation


Cells A2:G10001 contain Array formulas, as shown below:

Cells A2:A10001 formula: {=NormalDevA($N$2,$O$2,10000)}


Cells B2:B10001 formula: {=NormalDevA($N$3,$O$3,10000)}
Cells C2:C10001 formula: {=NormalDevA($N$4,$O$4,10000)}
Cells D2:D10001 formula: {=NormalDevA($N$5,$O$5,10000)}
Cells E2:E10001 formula: {=NormalDevA($N$6,$O$6,10000)}
Cells F2:F10001 formula: {=NormalDevA($N$7,$O$7,10000)}
Cells G2:G10001 formula: {=NormalDevA($N$8,$O$8,10000)}
Cells H2 formula: =A2+B2+C2*D2/(C2+D2)+E2*F2/(E2+F2)+G2 (copied down over the full data range).
10
NormalDevA is the PopTools expression for a Normal Distribution
The next term is the nominal (mean) value
The next term is the standard deviation
The final term is the trial number = 10,000 in this example

In the Excel implementation each cell would component value cell would contain the following
formula where RAND() is an Excel function and the next two terms are the mean and standard deviation,
respectively.

=NORMINV(RAND(),$P$2,$Q$2)

11

You might also like