Hello Bernardo, --------- If I understood your problem this script solve your problem: 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. 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. I would have thought that tracking how a (measuring) error propagates through a complex calculation would be a standard problem of statistics?? 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. Thank you, Jan
On Sep 9, 2010, at 6:50 AM, Jan private wrote:> Hello Bernardo, > > --------- > If I understood your problem this script solve your problem: > > 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. 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. > > I would have thought that tracking how a (measuring) error propagates > through a complex calculation would be a standard problem of > statistics?? 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. > > Thank you, > Jan > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
> q<-0.15 + c(-.1,0,.1) > h<-10 + c(-.1,0,.1) > > 5*q/h[3:1][1] 0.02475248 0.07500000 0.12626263 -- View this message in context: http://r.789695.n4.nabble.com/Re-Calculating-with-tolerances-error-propagation-tp2532640p2532991.html Sent from the R help mailing list archive at Nabble.com.
On Sep 9, 2010, at 6:50 AM, Jan private wrote:> Hello Bernardo, > > --------- > If I understood your problem this script solve your problem: > > 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 > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
"Jan private" <jrheinlaender at gmx.de> wrote in message news:1284029454.2740.361.camel at localhost.localdomain...> Hello Bernardo, > > --------- > If I understood your problem this script solve your problem: > > 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. 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. > > I would have thought that tracking how a (measuring) error propagates > through a complex calculation would be a standard problem of > statistics?? 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. > > Thank you, > Jan >Ahhh! "tracking how a (measuring) error propagates through a complex calculation" That doesn't depend only on values+errors, it also depends on the calculations, so - as you imply - you'd have to define a new data type and appropriate methods for all the mathematical operators (not just the binary ones!). Not a trivial task! If you don't already know it, you should look at "Evaluation of measurement data - Guide to the expression of uncertainty in measurement" http://www.bipm.org/utils/common/documents/jcgm/JCGM_100_2008_E.pdf especially section 5. Hope that helps, Keith J
On Sep 9, 2010, at 10:57 AM, David Winsemius wrote:> > On Sep 9, 2010, at 6:50 AM, Jan private wrote: > >> Hello Bernardo, >> >> --------- >> If I understood your problem this script solve your problem: >> >> 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. >> 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.There is a function, propagate, in the qpcR package that does incorporate statistical principles in handling error propagation. Thanks to the author, Dr. rer. nat. Andrej-Nikolai Spiess, for drawing it to my attention (and of course for writing it.). It appears that it should handle the data situation offered with only minor modifications. The first example is vary similar to your (more difficult) ratio problem. > install.packages(pkgs="qpcR", type="source") # binary install did not succeed on my Mac, but installing from source produced no errors or warnings. > require(qpcR) > q<- c( 0.15 , .1) > h<-c( 10 , .1) > EXPR <- expression(5*q/h) > DF <- cbind(q, h) > res <- propagate(expr = EXPR, data = DF, type = "stat", + do.sim = TRUE, verbose = TRUE) > res$summary Sim Perm Prop Mean 0.07500751 NaN 0.07500000 s.d. 0.05001970 NA 0.05000562 Median 0.07445724 NA NA MAD 0.04922935 NA NA Conf.lower -0.02332498 NA -0.02300922 Conf.upper 0.17475818 NA 0.17300922 (My only suggestion for enhancement would be a print or summary method that did not output every single simulated value.) Three methods for error propagation estimation are included: a) Monte- Carlo simulation using sampling from the data, b) Permutation, and c) Gaussian errors calculated via a Taylor series expansion. There is a rich set of worked examples. It appears to be capable of meeting a wide variety of challenges. -- David.> > -- > 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 Winsemius, MD West Hartford, CT