Uncertainty Propagation

This page did provide source code for the uncertainty-propagation classes that were described at the 49th annual Radio­bioassay and Radio­chemi­cal Meas­ure­ments Con­fer­ence in Jackson Hole, WY (http://www.rrmc-baer.org). That code was old and had not been improved for sev­eral years, but since 2003 it has been largely re­writ­ten, simplified, and brought into better con­formance with the C++ stand­ard. The original code predated the C++ stand­ard. Keith left it here for over three years, know­ing that it wasn’t pretty, but in early 2007 he replaced it with a new ver­sion. The old ver­sion worked and demon­strated the con­cepts, but it also showed clearly that the pro­gram­mer had much to learn about C++. The latter ob­serva­tion may still be true, but at least he has made signifi­cant progress.

The latest revisions were begun in late March 2007 and completed in March 2008, but with no work done be­tween April and February. So many distractions.

If you encounter any problems using these files, please con­tact Keith at Work@mccroan.com. Send con­struc­tive criti­cism to the same address.

There are actually three imple­men­ta­tions here. The first uses a smart pointer type defined in the header file upf.hpp. Except for the smart-pointer template, this ver­sion is prob­ably the simplest. The second imple­men­ta­tion uses the Boost li­brary, and boost::shared_ptr in par­ticular. The third (and most recent) imple­menta­tion also uses shared_ptr, but it makes more use of the PIMPL idiom to hide imple­menta­tion details from the appli­ca­tion, and, more importantly, it makes greater use of shared_ptr to reduce the cost of copy­ing large con­tainers, especially when return­ing them from func­tions. Since shared_ptr appears likely to become part of the STL even­tually, it seems reason­able to take ad­van­tage of it now, but if you prefer not to use the Boost li­brary, the first imple­men­ta­tion is self-contained.

Eventually two of the implementa­tions will dis­appear and one will remain.

Use whatever you like, and improve it to suit you. If you strongly like it or dis­like it, or if you just see ways to make it better, please give feed­back to Keith. The goal is to pro­vide a use­ful tool to labs or any­one else who needs to propa­gate uncertainty but gets bogged down in the math.

The current versions provide new fea­tures for out­put format­ting, including ostream manipu­lators to con­trol for­mat options such as:

It is even inter­national­ized (slightly) inas­much as it allows a choice of decimal point charac­ter (uses locale’s decimal point by default).

Note: Trying to write the code so that it works cor­rectly with four dif­fer­ent compilers has been a small challenge. Each sys­tem pre­sents its own prob­lems, some of which can be surprising.

Compressed Folder
(Click to download)
Description
upf1.zip First implementation, not using Boost
upf2.zip Second implementation, using boost::shared_ptr
upf3.zip Third implementation, with more sharing (for speed) and more information hiding

Minimal documentation (Microsoft Word): upfdoc.doc