As a spinoff from a homework we gave in our julia course at our department, I created a small package to do nonlinear uncertainty propagation, MonteCarloMeasurements.jl.

This package provides two types `Particles <: Real`

and `StaticParticles <: Real`

that represents a distribution of a floating point number, kind of like the type `Measurement`

from Measurements.jl. The difference compared to a `Measurement`

is that `Particles`

represent the distribution using a vector of unweighted particles, and can thus represent arbitrary distributions and handles nonlinear uncertainty propagation well. Functions like `f(x) = xÂ˛`

or `f(x) = sign(x)`

at `x=0`

, are not handled well using linear uncertainty propagation ala Measurements.jl.

The goal is to have a number of this type behave just as any other number while partaking in calculations. After a calculation, the `mean`

, `std`

etc. can be extracted from the number using the corresponding functions. `Particles`

also interact with Distributions.jl, so that you can call, e.g., `Normal(p)`

and get back a `Normal`

type from distributions or `fit(Gamma, p)`

to get a `Gamma`

distribution. Particles can also be iterated, asked for `maximum/minimum`

, `quantile`

etc.

The README contains some examples, benchmarks and pretty plots.

## Why

Convenience. Also, the benefit of using this number type instead of manually calling a function `f`

with perturbed inputs is that, at least in theory, each intermediate operation on a `Particles`

can exploit SIMD, since itâ€™s performed over a vector. If the function `f`

is called several times, however, the compiler might not be smart enough to SIMD the entire thing. Further, any dynamic dispatch is only paid for once, whereas it would be paid for `N`

times if doing things manually. One could perhaps also make an argument for cache locality being favorable for the `Particles`

type, but Iâ€™m not sure this holds for all examples. Primitive benchmarks in the readme show 15x-80x speedup for the considered examples.

The package will be registered once the new registration system is robust, for now

`] add https://github.com/baggepinnen/MonteCarloMeasurements.jl.git`

is the way to go.