A temporary sidetrack:
what is the accuracy of X+Y, X-Y, X*Y, X/Y ?
There is an easy but very informative and useful programming exercise here.
Implement X and Y as random numbers, with some distribution around some median. Error bounds are by convention those that encompass 68.3% of all values symmetrically around the median, 34.15% above the median, and 34.15% below the median. Repeat one of the operations above, creating a histogram of the results. After a sufficient number of iterations, find the median, and the error bounds. (For a normal distribution, the error bounds are exactly one standard deviation below and above the median.)
The same approach can be applied to investigate "black box" multivariate functions numerically, that for some reason or another cannot be solved analytically. Each result distribution per fixed input argument the represents one data point. The function can then be characterized in the desired input argument domain to any desired fidelity, by having enough data points.
To generate random numbers in any distribution \$P(x)\$, first calculate or find out the
cumulative distribution function \$F_x(x)\$,
$$F_x(x) = \int_{-\inf}^x P(\chi) \, d\chi$$
noting that \$F_x(-\inf) = 0\$ and \$F_x(+\inf) = 1\$. To generate a random number \$x\$, you first generate an uniform random number \$p\$, \$0 \le p \le 1\$, and then find \$x\$ such that \$F_x(x) = p\$. You can either calculate or approximate the inverse function, or you can use a binary search, because \$F_x(x)\$ is a nondecreasing function in \$x\$.
For a normal distribution with median/average \$\mu\$ and standard deviation \$\sigma\$,
$$F_x(x) = \frac{1}{2} + \frac{1}{2} \operatorname{erf}\left( \frac{x - \mu}{\sqrt{2} \sigma} \right)$$
where \$\operatorname{erf}()\$ is the
error function. Often the
Box–Muller method is preferable, though.
A variant is where you model the distribution as a simple interval, as a rectangular distribution. Within this interval, each value is equally likely; outside the range the probability is zero. This is called
interval arithmetic. Simply put, each variable
Z actually refers to a continuous interval, (
Zmin..
Zmax). Arithmetic binary operators are applied all four ways, with the result consisting of the minimum and the maximum of those results.
Because this distribution is rather unrealistic, it gives different results than when one uses the standard distribution (Gaussian) or any other more realistic distribution, but it can nevertheless be useful in some cases. For example, given X = 200±1% = 198..202 and Y = 100±1% = 99..101, interval arithmetic yields
- X + Y = 297 .. 303 = 300±1%
- X - Y = 97 .. 103 = 100±3%
- X * Y = 19602 .. 20402 ≃ 20002±2%
- X / Y ≃ 1.96 .. 2.04 = 2±2%
I like to point out these kind of programming experiments, because it is how I personally gain a more intuitive understanding of how imprecise values behave. One does not need to be a mathematician to be able to understand them and to use them to solve problems.