Re: [R] Inconsistent computation of an integral

2013-12-20 Thread William Dunlap
ll Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Aurélien Philippot [mailto:aurelien.philip...@gmail.com] Sent: Friday, December 20, 2013 8:59 AM To: William Dunlap; R-help@r-project.org Subject: Re: [R] Inconsistent computation of an integral Thanks William. I was convinced by pmax, until I pl

Re: [R] Inconsistent computation of an integral

2013-12-20 Thread Aurélien Philippot
Thanks William. I was convinced by pmax, until I played with the following example today. I tried to reproduce a computation from a paper. Here is the code: P<- function(x) { ab<-100*exp((0.0435-0.0269-0.5*0.3315^2)*4.3122+x*sqrt(4.3122)*0.3315) return(ab) } integrand<- function(x){ cd<- -1

Re: [R] Inconsistent computation of an integral

2013-12-19 Thread William Dunlap
I think you want to use pmax(x-50, 0), which returns a vector the length of x, instead of max(x-50,0), which returns a scalar. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Beha