object oriented software for uncertainty propagation n.
Skip this Video
Loading SlideShow in 5 Seconds..
Object-oriented Software for Uncertainty Propagation PowerPoint Presentation
Download Presentation
Object-oriented Software for Uncertainty Propagation

Object-oriented Software for Uncertainty Propagation

180 Vues Download Presentation
Télécharger la présentation

Object-oriented Software for Uncertainty Propagation

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Object-oriented Software forUncertainty Propagation Keith D. McCroan US EPA National Air and Radiation Environmental Laboratory

  2. Disclaimers • The views and opinions of the author expressed here do not necessarily reflect those of the Environmental Protection Agency • Reference here to any commercial product, process, or service does not imply its endorsement by the Environmental Protection Agency

  3. Motivation • Most of us recognize the importance of good uncertainty evaluation • Uncertainty propagation involves calculus, and many people forget their calculus after graduation (or before) • At best the math is usually tedious • So, sometimes uncertainty evaluation may be done incorrectly, incompletely, or not at all

  4. Believe It or Not • The most straightforward aspect of uncertainty evaluation is uncertainty propagation • The complexity of uncertainty propagation arises mostly through the repeated application of simple rules • In fact, uncertainty propagation is so “easy” that it can be done automatically in a shared software module, such as a Windows® DLL

  5. In a Nutshell • What follows is an approach for implementing automatic uncertainty propagation in a language, like C++, that allows the definition of new data types, with function and operator overloading • It permits the application programmer to focus on calculating results, while a software library propagates uncertainties in the background

  6. Terminology • For terminology and symbols, we follow the “GUM” (Guide to the Expression of Uncertainty in Measurement) • In particular, we use the terms standard uncertainty and combined standard uncertainty to mean “1-sigma uncertainty” and “total propagated (1-sigma) uncertainty”

  7. Mathematical Model • Uncertainty propagation begins with a mathematical model of the measurement • The model is written abstractly as Y=f(X1,X2,…,XN) where X1,X2,…,XN are input quantities and Y is the output quantity • A simple radiochemistry example might be: A=(NS/tS-NB/tB) / (EVRD)

  8. Input & Output Estimates • For each measurement, particular values x1,x2,…,xN, called input estimates, are plugged into the model and the output estimate, y, is calculated as y=f(x1,x2,…,xN) • Input estimates are often the “raw data” • Output estimates are the results of calculations

  9. Uncertainty PropagationFormula • The combined standard uncertainty of y is obtained from the equation: • This equation may be intimidating to anyone who is uncomfortable with calculus • But it is actually straightforward

  10. Propagating Uncertainty • The uncertainty propagation formula may be straightforward, but applying it can be tedious… • …especially if there are many input estimates and some of them are correlated • The biggest difficulty is in the calculation of the partial derivatives, f / xi (also called sensitivity coefficients)

  11. Differentiation • The rules for calculating derivatives of the functions typically used in laboratory measurements are well known and can be implemented in software • The uncertainty-propagation library is primarily a derivative calculator (with a few other functions thrown in)

  12. Some Differentiation Rules (Examples)

  13. New Data Types • The library exports 2 data types, which may be used in an application program: • Input estimate • Output estimate • In C++, these data types are implemented as classes (called InpEst and OutEst)

  14. Syntax • The syntax for calculating with input estimates and output estimates is the same as for ordinary floating-point numbers • E.g. one may write the following C++ code: A=(NS/tSNB/tB) / (E*V*R*D); • The syntax is the same regardless of whether the variables on the right are “floats”, input estimates, or output estimates • The difference is in the semantics

  15. The Client Application: • Declares variables of type “input estimate” and “output estimate” as necessary • Assigns values and standard uncertainties to the input estimates • Specifies the covariance for each pair of correlated input estimates • Calculates intermediate and final results (output estimates) using these variables

  16. The Payoff • The uncertainties and covariances of the calculated results are then available almost for free (i.e., with little effort) • The client application calls a library function to return the uncertainty of an output estimate • It can call another function to evaluate covariances (if needed)

  17. C++ Examples InpEst x1,x2,x3,x4; // Declare input estimates // Here are some of the ways to assign values // & uncertainties to input estimates x1 = InpEst(10, 2); // Value  uncertainty x2 = Poi(240); // Poisson distribution x3 = Rect(100, 3); // Rectangular dist. x4 = Tri(300, 5); // Triangular dist.

  18. Covariances • The covariance of any pair of input estimates may be specified. For example: Set_u(x1, x2) = 40; • Alternatively, the correlation coefficient may be specified: Set_r(x1, x2) = 0.92;

  19. Output Estimates • When the application performs a calculation involving input estimates and/or output estimates, the result is an output estimate • Both intermediate results and final results are output estimates

  20. Sensitivity Coefficients • Each output estimate has a value and an array of sensitivity coefficients • There is 1 sensitivity coefficient for each input estimate on which the value of the output estimate depends • The library propagates sensitivity coefficients in the background, without help from the programmer

  21. Combined Standard Uncertainty • The library propagates sensitivity coefficients automatically, but it calculates uncertainties only upon request • When an output estimate is calculated and stored in a variable, the application can obtain its combined standard uncertainty with a function call

  22. Example • Assume input estimates Ns, Nb, ts, and tb have been given values, and R is a variable of type “output estimate”. Calculate: R = Ns / ts  Nb / tb; • The variable R acquires the value indicated • And it automatically acquires 4 sensitivity coefficients: one for each of the input estimates from which it was calculated

  23. Example: Continued • When the result is calculated and stored in the variable R, the application can obtain its combined standard uncertainty using the expression u(R) • The library applies the uncertainty propagation formula to evaluate u(R) for the application

  24. Simplistic Example int main() { InpEst Ns, Nb, Eff, V, Y; // Declare variables: input estimates OutEst A; // Declare variable: output estimate float ts, tb; // Declare variables: floating-point numbers ts = tb = 6000; // Count times Ns = Poi(240); // Gross count (Poisson) Nb = Poi(86); // Blank count (Poisson) Eff = InpEst(0.364, 0.022); // Efficiency V = InpEst(1, 0.004); // Aliquant size Y = InpEst(0.84, 0.02); // Yield A = (Ns/ts - Nb/tb) / (Eff*V*Y); // Final result cout<<“The answer is “<<m(A)<<“+-”<<u(A)<<endl; // Show results return 0; }

  25. Output The program prints: The answer is 0.0839438+-0.0112566

  26. Summary • The right software makes uncertainty propagation easy -- for arbitrary measurement models • The propagation can be done automatically in a shared library module • You (and your programmer) can focus on calculating results and let the library propagate uncertainties for you

  27. For More Information • A handout is available here for more details of the implementation • All code is in the public domain: available at

  28. Questions?