lmfit / uncertainties

Transparent calculations with uncertainties on the quantities involved (aka "error propagation"); calculation of derivatives.
http://uncertainties.readthedocs.io/
Other
579 stars 73 forks source link

Error in only one direction #54

Closed pjacob2 closed 8 years ago

pjacob2 commented 8 years ago

I should preface this by saying that this is not really an issue report but rather a feature request.

I have a value for a conversion in a chemical reaction. The conversion is measured to be 100% which is the maximum theoretically possible. If I have 100% conversion I have used up all my starting material in the reaction and I obviously can’t use any more as it is all gone thus I can only feasibly have an error in the negative direction i.e. 1 (-0.05) instead of 1 (+-0.05). How would I represent that in uncertainties? I fear I haven’t found a method yet (or missed it) though I have come across this article saying it might not be possible (https://newton.cx/~peter/2013/04/propagating-uncertainties-the-lazy-and-absurd-way/ ) and this github conversation on the matter (https://github.com/lebigot/uncertainties/issues/25 ).

lebigot commented 8 years ago

This falls within the framework of linear error propagation theory: as indicated in the documentation of the module (http://pythonhosted.org/uncertainties/tech_guide.html#mathematical-definition-of-numbers-with-uncertainties), the nominal value of a number with uncertainty is slightly loosely defined but should be close to the average of the probability distribution that it represents; the standard deviation is the usual standard deviation. In your example, the average would be lower than 100%, and the representation of your distribution is average±std_dev (for instance 0.98±0.02).

Thus, the "error in one direction" concept is just one way of describing the distribution (that implies that the distribution peaks on one of its sides). Linear error propagation theory (and therefore the uncertainties module) describes the same distribution in the way described above. Both represent the same underlying probability distribution. So, yes, you can already describe the probability distribution that you described; it's just that the nominal value should be its average (not its mode).

If this is not clear, feel free to keep commenting in this issue.