JuliaPhysics / Measurements.jl

Error propagation calculator and library for physical measurements. It supports real and complex numbers with uncertainty, arbitrary precision calculations, operations with arrays, and numerical integration.
https://juliaphysics.github.io/Measurements.jl/stable/
MIT License
486 stars 37 forks source link

Support for alternative probability distributions (such as uniform) #33

Open alhirzel opened 5 years ago

alhirzel commented 5 years ago

For some engineering applications, it is very helpful to use uniform distributions rather than Gaussian distributions. Examples include statistical geometric tolerance stacks, round-off noise in signal processing, and worst-case timing analysis of real-time systems. This issue proposes broadly that Measurements.jl have the ability to express a measurement with any known distribution (e.g. utilizing Distributions.jl) and the ability to automatically track a representation of the distribution. Specifically, it would be excellent for the engineering community to have propagation of uniform distributions. An alternative to this would be the creation of a separate project in the spirit of Measurements.jl but for uniform distributions.

giordano commented 5 years ago

Thanks for your report. Honestly, I'm not going to implement this nice feature as I don't have much experience with error propagation in case of arbitrary probability distributions. Anyway I'll leave this ticket open for anyone willing to work on this.

A few days ago I came across this package: https://github.com/kahaaga/UncertainData.jl. This should be what you're looking for, but my understanding is that it doesn't support correlated quantities.

alhirzel commented 5 years ago

UncertainData.jl doesn't support analytic propagation of distributions. It appears this is on their radar for Normal distributions, but they cite Measurements.jl as a source of this behavior :).

I am not a statistician by any means, but I did a quick literature search and did not see much for propagation of uniform distributions. I think one approach that would work is tracking arbitrarily-complex piecewise linear distributions/PLDs (of which the uniform and triangular/trapezoidal distributions would be special cases). I would foresee having some concept of difference from a normal distribution to allow approximation by a normal distribution when "close enough".

giordano commented 5 years ago

@alhirzel you may be interested in this new package: https://github.com/baggepinnen/MonteCarloMeasurements.jl

mestinso commented 2 years ago

There are practically two options here: 1) Monte Carlo type analysis (mentioned above) <-- more general approach 2) Use the standard deviation associated with the error distributions of interest. E.g. for a uniform distribution, that would be (b-a)/sqrt(12). Standard deviations for other distributions are widely available in the literature. The output error distribution can generally be assumed to be normal due to the central limit theorem. Probably no specific action required except for a comment or two in the documentation.

With that said, I think there could be room for specifying degrees of freedom associated with each measurement, which would propagate to the output estimated degrees of freedom. Additionally, likely some helper functions for predicting the expanded uncertainty (ie the uncertainty bounds at a specific level of confidence), which would utilize the degrees of freedom would be nice.