From Torsten.Hothorn@rzmail.uni-erlangen.de  Fri Jan 12 07:25:11 2001
From: Torsten.Hothorn@rzmail.uni-erlangen.de (Torsten Hothorn)
Date: Fri, 12 Jan 2001 08:25:11 +0100 (MET)
Subject: [Rd] segmentation fault in integrate (PR#812)
In-Reply-To: <200101112149.WAA26997@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.21.0101120814190.31983-100000@artemis.imbe.med.uni-erlangen.de>


> I tried to integrate numerically a function wich is similar to the
> following:
> 
> > dummy <- function(x) { exp(-1*x) * dnorm(x) }
> > dummy(-100)
> [1] 0
> > dummy(-1000)
> [1] NaN
> > dummy(-10000)
> [1] NaN
> 
> If I choose the lower boundary to be too small integrate causes a
> segmentation fault:
> 
> > library(integrate)
> > integrate(dummy, -100, 0)$value
> [1] 1.387143
> > integrate(dummy, -1000, 0)$value
> [1] NaN
> Warning message:
> Ifail=1, maxpts was too small. Check the returned relerr! in: adapt(1,
> lower, upper, minpts, maxpts, functn, eps, ...)
> > integrate(dummy, -10000, 0)$value
> Segmentation fault

Running Version 1.2.0 Patched (2001-01-07) and integrate Version  2.2-3
on SuSE 6.4 gives:

> integrate(dummy, -1000000, 0)$value
[1] NaN
Warning message: 
Ifail=1, maxpts was too small. Check the returned relerr! in: adapt(1,
lower, upper, minpts, maxpts, functn, eps, ...) 

I has not able to reproduce the segfault ;-)

BTW: if one uses

> dummy <- function(x) { a <-  exp(-1*x) * dnorm(x); ifelse(is.na(a), 0,
a) }

this returns

> integrate(dummy, -100, 0)$value
[1] 1.387143
> integrate(dummy, -1000, 0, maxpts=1000)$value
[1] 0.6935715

Torsten

> 
> I'm running R.1.2.0 on Debian Linux.
> 
> Regards
> Achim
> 
> 
> > version
>          _                
> platform i686-pc-linux-gnu
> arch     i686             
> os       linux-gnu        
> system   i686, linux-gnu  
> status                    
> major    1                
> minor    2.0              
> year     2000             
> month    12               
> day      15               
> language R   
> 
> 
> 
> -------------------------
> 
> Achim Zeileis
> Institut fr Statistik
> Technische Universitt Wien
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] segmentation fault in integrate (PR#812)
Torsten Hothorn