# [R] Calculating with tolerances (error propagation)

David Winsemius dwinsemius at comcast.net
Thu Sep 9 16:57:52 CEST 2010

```On Sep 9, 2010, at 6:50 AM, Jan private wrote:

> Hello Bernardo,
>
> ---------
>
> q<-0.15 + c(-.1,0,.1)
> h<-10 + c(-.1,0,.1)
> 5*q*h
> [1]  2.475  7.500 12.625
> ---------
>
> OK, this solves the simple example.
> But what if the example is not that simple. E.g.
>
> P = 5 * q/h
>
> Here, to get the maximum tolerances for P, we need to divide the
> maximum
> value for q by the minimum value for h, and vice versa.

Have you considered the division by zero problems?

> Is there any way
> to do this automatically, without thinking about every single step?
>
> There is a thing called interval arithmetic (I saw it as an Octave
> package) which would do something like this.

(Sorry for the blank reply posting. Serum caffeine has not yet reached
optimal levels.)

Is it possible that interval arithmetic would produce statistically
incorrect tolerance calculation, and that be why it has not been added
to R? Those tolerance intervals are presumably some sort of
(unspecified) prediction intervals (i.e. contain 95% or 63% or some
fraction of a large sample) and combinations under mathematical
operations are not going to be properly derived by c( min(XY),
max(XY) ) since those are not calculated with any understanding of
combining variances of functions on random variables.

--
David.
>
> I would have thought that tracking how a (measuring) error propagates
> through a complex calculation would be a standard problem of
> statistics??

In probability theory, anyway.

> In other words, I am looking for a data type which is a
> number with a deviation +- somehow attached to it, with binary
> operators
> that automatically knows how to handle the deviation.

There is the suite of packages that represent theoretic random
variables and support mathematical operations on them.

See distrDoc and the rest of that suite.

--
David.
>
> Thank you,
> Jan
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help