[Rd] inconsistent results when calling functions with other func (PR#869)

Paul.White@dsto.defence.gov.au Paul.White@dsto.defence.gov.au
Thu, 8 Mar 2001 08:34:51 +0100 (MET)


Hello Bug people,

I have an unexpected behavior and am unsure whether the problem is in my
thinking, my implementation or the program R.

Basically I get two different answers depending on how I call a function
which takes other functions as arguments as indicated below.
To me it should make no difference if f is a function that returns the
function g then z(f(x)) whould give the same as
y<- f(x)
z(y)
but I appear to get different answers as below. I have not distilled the
problem down to something you can replicate in total but have I done
something obviously wrong ?

Regards
Paul White 
ps I just checked with 1.2.2 and it still has the same behavior.

Version:
 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status =
 major = 1
 minor = 2.1
 year = 2001
 month = 01
 day = 15
 language = R


> risk <- function(f,g,H,lower.limits,upper.limits) 
+ {   prob.of.fracture <-  function(x)
+       { a  <- x[1] 
+         kc <- x[2] 
+         f(a) * g(kc) * H(a,kc) }
+
adapt(2,lower.limits,upper.limits,minpts=200,maxpts=20000,prob.of.fracture,e
ps=1e-3) }
>
risk(eifs.at.time.using.density(5000,eifs,1e-4,2),g,H,c(0.001,20),c(.5,60))
[1] 1.999471
       value       relerr       minpts       lenwrk        ifail 
    28.39852 0.0003455776          627         2803            0 
> 
> eifs.5000 <- eifs.at.time.using.density(5000,eifs,1e-4,2)
[1] 1.999471
> risk(eifs.5000,g,H,c(0.001,20),c(.5,60))
       value       relerr       minpts       lenwrk        ifail 
5.461088e-13 0.0006449058          741         2803            0 


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._