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

pubs.acs.

org/jchemeduc Technology Report

Monte Carlo Uncertainty Propagation with the NIST Uncertainty


Machine
Daniel R. Albert*

Cite This: J. Chem. Educ. 2020, 97, 1491−1494 Read Online

ACCESS Metrics & More Article Recommendations


Downloaded via UNIV INDUSTRIAL DE SANTANDER on November 20, 2020 at 17:10:50 (UTC).
See https://pubs.acs.org/sharingguidelines for options on how to legitimately share published articles.

ABSTRACT: Monte Carlo simulations for uncertainty propaga-


tion take as inputs the uncertainty distribution for each variable
and an equation for the calculation of a desired quantity. The
desired quantity is then calculated by randomly drawing from the
specified uncertainty distributions of the input variables. This
calculation is then repeated many times (often 106 or greater) with
new random drawings each time. The resulting uncertainty
distribution of the calculated value is directly obtained from the
many random trials. Monte Carlo uncertainty propagation has the
advantage of both being easy to interpret and allowing for a wide
variety of uncertainty distributions. Monte Carlo uncertainty
propagation methods have not been widely used in the
undergraduate curriculum due to the lack of availability of easy
to implement solutions for carrying out these simulations. Fortunately, the National Institute of Standards and Technology (NIST)
developed a Monte Carlo uncertainty propagation calculator, “NIST Uncertainty Machine”, that is freely available and accessible via
a web interface. The NIST Uncertainty Machine makes the propagation of uncertainty with Monte Carlo simulations easy to
implement in the undergraduate curriculum.
KEYWORDS: Upper-Division Undergraduate, Physical Chemistry, Analytical Chemistry, Problem Solving/Decision Making,
Mathematics/Symbolic Mathematics

■ INTRODUCTION
Determination of measurement uncertainty and subsequent
calculated value of the desired quantity is then determined by
randomly drawing an input value from each of the specified
determination of the uncertainty of a value calculated from the uncertainty distributions and using the randomly drawn values
measured values is an important and core component of in the defined equation. The probability for randomly drawing a
scientific measurement in the undergraduate chemistry particular input quantity is defined by the specified uncertainty
curriculum.1 Uncertainty propagation is typically introduced distribution. This calculation is then repeated with new
into the curriculum through significant figure rules in randomly drawn quantities many times (often 106 or greater)
introductory chemistry courses and then treated in a more to generate a large number of calculated values for the desired
sophisticated manner in undergraduate physical or analytical quantity. The uncertainty distribution of the calculated output
chemistry courses using a calculus-based approach. We could value is determined by direct examination of the 106 or more
start introducing more reliable uncertainty estimation methods calculated quantities.6,7 A Monte Carlo simulation routine for
earlier if they were easier to incorporate.2 uncertainty propagation has been previously described in the
Students have difficulty understanding why the calculus-based Journal of Chemical Education by Demas et al. using a Mathcad
approach works and often make mistakes computing partial routine that can handle up to four input quantities.5 Monte
derivatives. Hughes and Hase developed an intuitive introduc- Carlo methods can be advantageous as compared to the
tion to uncertainty propagation using functionals to help calculus-based approach for error propagation by providing a
students visualize and better understand the calculus-based
approach for the calculation of uncertainty.3 Other approaches Received: January 31, 2020
for propagation of uncertainty have involved numerical methods Revised: March 18, 2020
and Monte Carlo methods.4−7 Published: April 15, 2020
Monte Carlo simulations for uncertainty propagation take as
inputs the uncertainty distribution for each variable and an
equation for the calculation of a desired quantity. A single
© 2020 American Chemical Society and
Division of Chemical Education, Inc. https://dx.doi.org/10.1021/acs.jchemed.0c00096
1491 J. Chem. Educ. 2020, 97, 1491−1494
Journal of Chemical Education pubs.acs.org/jchemeduc Technology Report

Figure 1. Screen capture from the calculation input page for the NIST Uncertainty Machine (http://uncertainty.nist.gov).

relatively easy to interpret understanding of the calculation for NIST in the “Guide to the Uncertainty in Measurement”
students and by allowing for the propagation of a wide variety of specifically in Supplement 1.7 A user can specify up to 15 input
uncertainty distributions.4,5 quantities and underlying uncertainty distributions, along with a
In the teaching laboratory, students are often required to formula for calculation of the desired output. A Monte Carlo
estimate underlying uncertainty distributions of various calculation of 105 to 5 × 106 simulations, as defined by the user,
measurements in the interest of time. Many measurements in is then run.8
the chemistry laboratory (interpolation of an analog scale, Input quantities allow for a large variety of uncertainty
reading of a nonfluctuating digital signal, and others) are best distributions to be considered with various prompts given to
estimated with uncertainty distributions that are non-Guassian specify the underlying uncertainty. Examples that typically arise
(e.g., triangular uncertainty distributions, uniform uncertainty in the undergraduate chemistry laboratory are the following:
distributions, etc.).5,6 Monte Carlo methods for uncertainty Gaussian where the user must specify a mean and standard
propagation easily incorporate various uncertainty distributions. deviation; Uniform/Rectangular where the user must specify a
Despite these convenient features, Monte Carlo methods have left and right end point; Triangular Symmetric where the user
traditionally been difficult to integrate into the chemistry must specify a left and right end point; and Triangular
curriculum due to a lack of availability of easy to implement Asymmetric where the user must specify a left end point,
solutions for carrying out these simulations.5 mode, and right end point. A number of other options and ways
A tool developed by the National Institutes of Standards and to input the uncertainty distributions also exist. Users are also
Technology (NIST) known as the “NIST Uncertainty Machine” able to define correlations between uncertainties in various
makes the propagation of error via the Monte Carlo method variables.8
readily available via a web interface (http://uncertainty.nist. After specifying input variables and their associated
gov).8 The NIST Uncertainty Machine eliminates barriers to uncertainty distribution, a user simply specifies parameters for
implementation of Monte Carlo methods and provides a the Monte Carlo calculation and the formula for calculating the
reliable, effective, and robust approach for propagation of error. output. The Monte Carlo parameters are simply the number of
NIST Uncertainty Machine simulations to run (between 105 and 5 × 106) and an input
The NIST Uncertainty Machine was developed for the kernel (1−100) that allows for exact reproducibility of
propagation of uncertainty in measurement as described by calculations. The formula for calculating the output quantity
1492 https://dx.doi.org/10.1021/acs.jchemed.0c00096
J. Chem. Educ. 2020, 97, 1491−1494
Journal of Chemical Education pubs.acs.org/jchemeduc Technology Report

Figure 2. Screen capture from the calculation results page of the NIST uncertainty machine (http://uncertainty.nist.gov). The solid blue line
represents the probability density from the Monte Carlo simulation. The dotted red line represents the probability density of a Gaussian distribution
that has the same mean and standard deviation as the Monte Carlo simulation data.

allows for many functions as defined in the R programming and 1.000 g of magnesium could be massed on a digital balance
language.9 with a specified uncertainty of plus or minus 0.001 g. The
After the user runs the computation, the NIST Uncertainty uncertainty can be interpreted as uniform/rectangular, meaning
Machine displays the output data for both the Monte Carlo all values of the mass between 0.999 and 1.001 g are equally
method and the traditionally used calculus-based approach. The probable. The temperature of the gas could be measured with a
many simulations (approximately 106) are analyzed to provide standard thermometer that involves interpolation of a scale
standard descriptive statistics (mean, standard deviation, arriving in an asymmetric triangular distribution of the
median, and median absolute deviation), coverage intervals for uncertainty where the mode is the estimated value, say 27.2
defining the extremes to encapsulate certain percentages of the °C in this case, and the left and right end points are 27 and 28 °C.
trials (68%, 90%, 95%, and 99%), and an analysis of the The pressure could be measured using a digital probe. If the
uncertainty contribution of each variable based on an analysis of digital probe reads a constant pressure of 1.021 atm, then the
variance (ANOVA). The analysis of the uncertainty contribu- underlying uncertainty in the measurement is a uniform/
tion of each variable specifies the percentage contribution of rectangular distribution between 1.0205 and 1.0215 atm. The
each input variable to the uncertainty of the calculated value. volume of the container holding the gas could have been
Finally, the probability distribution of the calculated output characterized by a series of measurements and determined to be
quantity is graphically displayed for both the Monte Carlo 994.2 mL with a standard deviation of 0.3 mL.
method along with a Gaussian distribution with an equivalent The equation for the calculation of the gas constant is then
mean and standard deviation. The underlying data can be saved given by
as text files and image files.8,9 The provided statistical analysis of
the many random trials is a way of analyzing the output V
uncertainty distribution. The provided data also includes the raw R=
P ( 1000 )
mMg
outputs for each of the many random trials which allows the user
to define alternative ways of describing the calculated value and
( 24.305 )(T°C + 273.15) (1)
its underlying uncertainty that are appropriate for the output
uncertainty distribution. where R is the gas constant in units of L atm/mol K, P is the
pressure in atmospheres, V is the volume in milliliters, mMg is the
Example Calculation mass of magnesium in grams, and T°C is the temperature in
To illustrate the utility of the NIST Uncertainty Machine for the degrees Celsius. The calculation defined in eq 1 is performed
calculation of uncertainty via the Monte Carlo method, a many times (approximately 106) with a new random value
common example from the chemistry curriculum of calculating chosen for each variable (P, V, mMg, and T°C), as defined by its
the gas constant (R) using the ideal gas law is presented.10 uncertainty distribution, every time the calculation is performed.
An amount of gas could be produced via the reaction of an An example of the interface for calculation inputs is shown in
amount of magnesium metal with acid to produce hydrogen gas Figure 1, and the interface for calculation outputs is shown in
(H2). In this case, the metal could serve as the limiting reagent, Figure 2.
1493 https://dx.doi.org/10.1021/acs.jchemed.0c00096
J. Chem. Educ. 2020, 97, 1491−1494
Journal of Chemical Education


pubs.acs.org/jchemeduc Technology Report

The calculated value of the gas constant, R, from the Monte ACKNOWLEDGMENTS
Carlo simulation defined above and in Figure 1 is 0.082088 ± D.R.A. would like to thank the physical chemistry students at
0.000083 L atm/mol K. The distribution of calculated values is Millersville University for their willingness to experiment with
shown as the solid blue curve in Figure 2. The curve shows some and use the NIST Uncertainty Machine for propagation of
asymmetry due to the asymmetric triangular distribution used uncertainty.


for the underlying uncertainty associated with the measurement
of temperature. The ANOVA analysis of the Monte Carlo REFERENCES
simulation shows that the largest contributor to the uncertainty (1) Wenzel, T. J.; McCoy, A. B.; Landis, C. R. An Overview of the
in the calculation comes from the temperature measurement. Changes in the 2015 ACS Guidelines for Bachelor’s Degree Programs.
This is in agreement with standard rules of thumb that in J. Chem. Educ. 2015, 92, 965−968.
multiplication/division the main contributor to the calculated (2) (a) Schwartz, L. M. Propagation of Significant Figures. J. Chem.
uncertainty is the variable with the largest relative uncertainty. Educ. 1985, 62, 693−697. (b) Earl, B. L. A Comment on Significant
The uncertainty contribution analysis allows students to easily Figures and Propagation of Uncertainty. J. Chem. Educ. 1988, 65, 186−
see what aspects of the experiment influence the uncertainty of 187.
the calculated value. Knowing the main contributors toward the (3) Hughes, I. G.; Hase, T. P. A. Error Propagation: A Functional
uncertainty allows for reflection on areas of an experiment to Approach. J. Chem. Educ. 2012, 89, 821−822.
(4) Tellinghuisen, J. Using Least Squares for Error Propagation. J.
focus on improving or better characterizing. Chem. Educ. 2015, 92, 864−870.
Students find the NIST Uncertainty Machine easy to use, and (5) Gardenier, G. H.; Gui, F.; Demas, J. N. Error Propagation Made
the number of errors in uncertainty calculations seems to be Easy − Or at Least Easier. J. Chem. Educ. 2011, 88, 916−920.
significantly reduced as compared with that from the calculus- (6) Possolo, A.l.; Iyer, H. K. Concepts and tools for the evaluation of
based approach. The use of the Monte Carlo method for error measurement uncertainty. Rev. Sci. Instrum. 2017, 88, 011301.
propagation allows for students to focus more on defining the (7) (a) Taylor, N.; Kuyatt, C. E. Guidelines for Evaluating and
uncertainties of variables and interpreting their influence on the Expressing the Uncertainty of NIST Measurement Results; NIST
uncertainty of the calculated result instead of on the mechanics Technical Note 1297; National Institute of Standards and Technology:
of taking partial derivatives. Gaithersburg, MD, 1994. (b) Joint Committee for Guides in


Metrology. Evaluation of Measurement DataGuide to the Expression
of Uncertainty in Measurement; International Bureau of Weights and
CONCLUSIONS Measures (BIPM), S̀evres, France, 2008; BIPM, IEC, IFCC, ILAC,
The NIST Uncertainty Machine makes the Monte Carlo ISO, IUPAC, IUPAP, OIML, JCGM100:2008, GUM 1995 with minor
method for error propagation readily available via a web corrections.
interface. Monte Carlo error propagation methods allow (8) Lafarge, T.; Possolo, A. The NIST Uncertainty Machine. NCSLI
Measure 2015, 10, 20−27.
students to think about the underlying uncertainty distribution
(9) Lafarge, T.; Possolo, A. NIST Uncertainty MachineUser’s
of their measurements while building a mental construct of the Manual; 2018, https://uncertainty.nist.gov/
way in which uncertainty is propagated through a calculation. By NISTUncertaintyMachine-UserManual.pdf (22 January 2020).
using a freely available tool for uncertainty calculations, students (10) Olsen, R. J.; Sattar, S. Measuring the Gas Constant R:
are able to have ready access to the resource even after leaving Propagation of Uncertainty and Statistics. J. Chem. Educ. 2013, 90,
their undergraduate studies. Since Monte Carlo error prop- 790−792.
agation methods do not rely on calculus, more meaningful and
sophisticated error propagation teaching could take place earlier
in the chemistry curriculum. Connecting students to author-
itative resources such as the NIST Guide to the Uncertainty of
Measurement and the NIST Uncertainty Machine gives them
access to the same tools utilized by practicing scientists. The
relevance and now relative ease of Monte Carlo methods for
error propagation should make this method appealing for
undergraduate instructors teaching about uncertainty propaga-
tion. Monte Carlo methods and calculus-based approaches both
provide valid and reliable solutions for error propagation in the
vast majority of cases. The effectiveness of each approach, or
combination of approaches, for learning uncertainty propaga-
tion is an open question and worthy of further exploration.

■ AUTHOR INFORMATION
Corresponding Author
Daniel R. Albert − Chemistry Department, Millersville University,
Millersville, Pennsylvania 17551, United States; orcid.org/
0000-0003-4817-3915; Email: daniel.albert@millersville.edu
Complete contact information is available at:
https://pubs.acs.org/10.1021/acs.jchemed.0c00096

Notes
The author declares no competing financial interest.
1494 https://dx.doi.org/10.1021/acs.jchemed.0c00096
J. Chem. Educ. 2020, 97, 1491−1494

You might also like