Uncertainty Propagation Software

This page did provide source code for the uncertainty-​propa­ga­tion classes that were de­scribed at the 49th annual Radio­bio­assay and Radio­chemi­cal Meas­ure­ments Con­fer­ence in Jackson Hole, WY (http://www.rrmc.co). That code was old and had not been im­proved for sev­eral years, but since 2003 it has been largely re­writ­ten, simpli­fied, and brought into better con­form­ity with the C++ stand­ard. The original code pre­dated the C++ stand­ard. I left it here for over three years, know­ing that it wasn’t pretty, but in early 2007 I 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 com­pleted 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 send a note to Work@mccroan.com. Send con­struc­tive criti­cism to the same address.

From March 2008 through June 2011 there were three imple­men­ta­tions here. The first used a smart pointer type defined in the header file upf.hpp. Except for the smart-​pointer tem­plate, this ver­sion was prob­ably the simplest. The second imple­men­ta­tion used the Boost li­brary, and boost::shared_ptr in par­ticular. The third (and last) imple­menta­tion also used shared_ptr, but it made more use of the PIMPL idiom to hide imple­menta­tion details from the appli­ca­tion, and, more im­por­tant­ly, it made better use of shared_ptr to reduce the cost of copy­ing large con­tainers, especially when return­ing them from func­tions. I said from the start that even­tual­ly two of the imple­men­ta­tions would dis­appear and only one would remain. In 2011, I followed through and archived the first two. Only the third one is still avail­able.

In August I mod­ified reps.hpp and reps.cpp to use a more stand­ard ver­sion of the pro­visional means al­go­rithm. These files pro­vide a few ex­tra tools for Type A evalua­tions of un­cer­tain­ty and co­variance, but they are not criti­cal com­po­nents of the sys­tem. Later I may in­clude a class for weight­ed lin­ear re­gres­sion, but it still needs some refinements.

Use the code as 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 me feed­back. My goal is to pro­vide a use­ful tool to labs or any­one else who needs to propa­gate un­cer­tainty but gets bogged down in the math.

The current version provides fea­tures for out­put for­mat­ting, in­clud­ing ostream manipu­lators to con­trol for­mat options such as:

  • choice of stand­ard or expanded uncer­tainty format
  • number of digits in the rounded uncer­tainty (with an op­tion to use the stream’s precision)
  • coverage factor or level of con­fi­dence (based on effec­tive de­grees of freedom)
  • grouping of digits

It is even inter­national­ized (slightly) inas­much as it allows a choice of deci­mal point char­ac­ter (uses locale’s deci­mal point by de­fault). How­ever, as writ­ten it does not sup­port Unicode or wchar_t.

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

Compressed Folder
(Click to download)
Description
upf1.zip First imple­men­ta­tion, not us­ing Boost (removed)
upf2.zip Second imple­men­ta­tion, using boost::​shared_ptr (removed)
upf3.zip Third imple­men­ta­tion, with more sharing (for speed) and more in­for­ma­tion hiding

Minimal docu­men­ta­tion: pdf.pngupfdoc.pdf