Uncertainty Propagation Software
This page did provide source code for the uncertainty-propagation classes that were described at the 49th annual Radiobioassay and Radiochemical Measurements Conference in Jackson Hole, WY (http://www.rrmc.co). That code was old and had not been improved for several years, but since 2003 it has been largely rewritten, simplified, and brought into better conformity with the C++ standard. The original code predated the C++ standard. I left it here for over three years, knowing that it wasn’t pretty, but in early 2007 I replaced it with a new version. The old version worked and demonstrated the concepts, but it also showed clearly that the programmer had much to learn about C++. The latter observation may still be true, but at least he has made significant progress.
The latest revisions were begun in late March 2007 and completed in March 2008, but with no work done between April and February. So many distractions.
If you encounter any problems using these files, please send a note to Work@mccroan.com. Send constructive criticism to the same address.
From March 2008 through June 2011 there were three implementations here. The first used a smart
pointer type defined in the header file
upf.hpp. Except for the smart-pointer template, this
version was probably the simplest. The second implementation used the Boost library, and
boost::shared_ptr in particular. The third (and last) implementation
shared_ptr, but it made more use of the PIMPL idiom to hide
implementation details from the application, and, more importantly, it made
better use of
shared_ptr to reduce the cost
of copying large containers, especially when returning them from functions. I said
from the start that eventually two of the implementations would disappear and only one would remain.
In 2011, I followed through and archived the first two. Only the third one is still available.
In August I modified
reps.cpp to use a more standard version of the
provisional means algorithm. These files provide a few extra tools for Type A evaluations of
uncertainty and covariance, but they are not critical components of the system.
Later I may include a class for weighted linear regression, but it still needs some refinements.
Use the code as you like, and improve it to suit you. If you strongly like it or dislike it, or if you just see ways to make it better, please give me feedback. My goal is to provide a useful tool to labs or anyone else who needs to propagate uncertainty but gets bogged down in the math.
The current version provides features for output formatting, including ostream manipulators to control format options such as:
- choice of standard or expanded uncertainty format
- number of digits in the rounded uncertainty (with an option to use the stream’s precision)
- coverage factor or level of confidence (based on effective degrees of freedom)
- grouping of digits
It is even internationalized (slightly) inasmuch as it allows a choice of
decimal point character (uses locale’s decimal point by default). However, as written
it does not support Unicode or
Note: Trying to write the code so that it works correctly with four different compilers has been a small challenge. Each system presents its own problems, some of which can be surprising.
(Click to download)
|upf1.zip||First implementation, not using Boost (removed)|
|upf2.zip||Second implementation, using
|upf3.zip||Third implementation, with more sharing (for speed) and more information hiding|
Minimal documentation: upfdoc.pdf