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

Slides:



Advertisements
Similar presentations
Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
Advertisements

Fundamentals of Python: From First Programs Through Data Structures Chapter 2 Software Development, Data Types, and Expressions.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Kernighan/Ritchie: Kelley/Pohl:
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 4 By Herb I. Gross and Richard A. Medeiros next.
Guide to the Expression of Uncertainty in Measurement Keith D. McCroan MARLAP Uncertainty Workshop October 24, 2005 Stateline, Nevada.
EVALUATING BIOASSAY UNCERTANITY USING GUM WORKBENCH ® HPS TECHNICAL SEMINAR April 15, 2011 Brian K. Culligan Fellow Scientist Bioassay Laboratory Savannah.
MARLAP Measurement Uncertainty
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Lect11EEE 2021 Inverse Laplace Transformations Dr. Holbert February 27, 2008.
Level 1 Laboratories University of Surrey, Physics Dept, Level 1 Labs, Oct 2007 Handling & Propagation of Errors : A simple approach 1.
Matlab Matlab is a powerful mathematical tool and this tutorial is intended to be an introduction to some of the functions that you might find useful.
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
Let remember from the previous lesson what is Knowledge representation
Intro to Object-Oriented (“OO”) Design. OO Design Simplified methodology 1. Write down detailed description of problem 2. Identify all (relevant) nouns.
 2007 Pearson Education, Inc. All rights reserved C Program Control.
Guide To UNIX Using Linux Third Edition
Generation & Propagation of Uncertainty Analysis P M V Subbarao Professor Mechanical Engineering Department A Measure of Confidence Level in compound Experiments…..
C++ fundamentals.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
CIS Computer Programming Logic
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
MARLAP Chapter 19 Measurement Uncertainty
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Combined Uncertainty P M V Subbarao Professor Mechanical Engineering Department A Model for Propagation of Uncertainty ….
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Computer Science 101 Introduction to Programming.
Ordinary Differential Equations
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Keith D. McCroan US EPA National Air and Radiation Environmental Laboratory.
MATLAB Basics. The following screen will appear when you start up Matlab. All of the commands that will be discussed should be typed at the >> prompt.
Algorithms and Algorithm Analysis The “fun” stuff.
1 Analysis of Algorithms CS 105 Introduction to Data Structures and Algorithms.
Introduction to Data Structures and Algorithms CS 110: Data Structures and Algorithms First Semester,
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
The Software Development Process
ECSE Software Engineering 1I HO 4 © HY 2012 Lecture 4 Formal Methods A Library System Specification (Continued) From Specification to Design.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
MARLAP Chapter 20 Detection and Quantification Limits Keith McCroan Bioassay, Analytical & Environmental Radiochemistry Conference 2004.
College Algebra Sixth Edition James Stewart Lothar Redlin Saleem Watson.
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 1 Manipulating Data Concepts Covered: Literal values, variables and Types Variables.
Chapter 3: Developing Class Methods Object-Oriented Program Development Using Java: A Class-Centered Approach.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Chapter 7 The Laplace Transform
Exercise 3 Example> Write a C function that implements /* input : integer value n output : */ int f ( int n ) { int i, sum=0; for (i=1;i
Advanced Engineering Mathematics, 7 th Edition Peter V. O’Neil © 2012 Cengage Learning Engineering. All Rights Reserved. CHAPTER 4 Series Solutions.
72 4/11/98 CSE 143 Abstract Data Types [Sections , ]
CHAPTER- 3.2 ERROR ANALYSIS. 3.3 SPECIFIC ERROR FORMULAS  The expressions of Equations (3.13) and (3.14) were derived for the general relationship of.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
In C programming, one of the frequently arising problem is to handle similar types of data. For example: If the user want to store marks of 100 students.
Sec  Determine whether relations between two variables are functions; Use function notation.  Find the domains of functions.  Use functions to.
Arrays Chapter 7.
Lecture 4: Expressions and Variables
Measurement Uncertainty and Traceability
Revision Lecture
Lecture 3 of Computer Science II
Introduction to Computer Programming
Constructive Cost Model
Data Flow Analysis Compiler Design
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.

Propagation of Error Berlin Chen
Presentation transcript:

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

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

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

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

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

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”

Mathematical Model Uncertainty propagation begins with a mathematical model of the measurement The model is written abstractly as Y=f(X 1,X 2,…,X N ) where X 1,X 2,…,X N are input quantities and Y is the output quantity A simple radiochemistry example might be: A=(N S /t S  N B /t B ) / (EVRD)

Input & Output Estimates For each measurement, particular values x 1,x 2,…,x N, called input estimates, are plugged into the model and the output estimate, y, is calculated as y=f(x 1,x 2,…,x N ) Input estimates are often the “raw data” Output estimates are the results of calculations

Uncertainty Propagation Formula 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

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 /  x i (also called sensitivity coefficients)

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)

Some Differentiation Rules (Examples)

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)

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

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

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)

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.

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;

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

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

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

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

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

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; }

The program prints: The answer is Output

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

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

Questions?