Does anyone know if R have any problems with the exponential random number generation (function rexp)? I comment it because I executed data<-sort(rexp(100)) plot(data,dexp(data)/(1-pexp(data)),type="l") and the graphic isn't constant. (Note: exponential distribution have a constant hazard failure rate). Thank you, Juan -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi Juan It looks constant to me. Note the range of the values on the second axis !!! Sometimes you even get a warning about this Warning message: relative range of values = 22.5 * EPS, is small (axis 2). Note also: By calling your variable ``data'' you are over-writting a function of the same name (I do not think it did any harm in your example). Cheers Ole Juan Ramon Gonzalez wrote:> > Does anyone know if R have any problems with the exponential random number > generation (function rexp)? > > I comment it because I executed > > data<-sort(rexp(100)) > plot(data,dexp(data)/(1-pexp(data)),type="l") > > and the graphic isn't constant. > > (Note: exponential distribution have a constant hazard failure rate). > > Thank you, > > Juan > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help 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-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Ole F. Christensen Department of Mathematics and Statistics Fylde College, Lancaster University Lancaster, LA1 4YF, England -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Juan Ramon Gonzalez wrote:> > Does anyone know if R have any problems with the exponential random number > generation (function rexp)? > > I comment it because I executed > > data<-sort(rexp(100)) > plot(data,dexp(data)/(1-pexp(data)),type="l") > > and the graphic isn't constant. > > (Note: exponential distribution have a constant hazard failure rate).Well, plot() scales the "y"-values to fit best into the area: data <- sort(rexp(100)) dexp(data)/(1-pexp(data)) # all 1 ??? dexp(data)/(1-pexp(data)) - 1 # almost !!>From the computational point of view everything is looking very well,isn't it? Maybe you would like to set a ylim as in plot(data,dexp(data)/(1-pexp(data)),type="l", ylim =c(0,2)) Uwe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Have you looked at the range of the numbers? I got> range(dexp(data)/(1-pexp(data)))[1] 1 1 and range(dexp(data)/(1-pexp(data)))-1.0 [1] -1.665335e-15 1.110223e-15 Andy> -----Original Message----- > From: Juan Ramon Gonzalez [mailto:jrgonzalez at ico.scs.es] > Sent: Friday, May 03, 2002 9:34 AM > To: r-help at stat.math.ethz.ch > Subject: [R] problems with rexp ? > > > Does anyone know if R have any problems with the exponential > random number > generation (function rexp)? > > I comment it because I executed > > data<-sort(rexp(100)) > plot(data,dexp(data)/(1-pexp(data)),type="l") > > and the graphic isn't constant. > > (Note: exponential distribution have a constant hazard failure rate). > > Thank you, > > Juan > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > -.-.-.-.-.-.-.-.- > r-help 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-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._._._._._._._ >------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it. ============================================================================= -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 3 May 2002, Juan Ramon Gonzalez wrote:> Does anyone know if R have any problems with the exponential random number > generation (function rexp)? > > I comment it because I executed > > data<-sort(rexp(100)) > plot(data,dexp(data)/(1-pexp(data)),type="l") > > and the graphic isn't constant.Try> data<-sort(rexp(100)) > plot(data,dexp(data)/(1-pexp(data)),type="l", ylim = c(0, 2))and you may guess what's going on. (Has nothing to do with random number generation!) G?ran> (Note: exponential distribution have a constant hazard failure rate). > > Thank you, > > Juan > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help 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-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- G?ran Brostr?m tel: +46 90 786 5223 professor fax: +46 90 786 6614 Department of Statistics http://www.stat.umu.se/egna/gb/ Ume? University SE-90187 Ume?, Sweden e-mail: gb at stat.umu.se -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
instead of (1 - pexp(data)), try using pexp(data, lower.tail=FALSE), for a more accurate calculation of upper tail probabilities. R. Woodrow Setzer, Jr. Phone: (919) 541-0128 Experimental Toxicology Division Fax: (919) 541-5394 Pharmacokinetics Branch NHEERL MD-74; US EPA; RTP, NC 27711 |---------+------------------------------> | | Juan Ramon Gonzalez| | | <jrgonzalez at ico.scs| | | .es> | | | Sent by: | | | owner-r-help at stat.m| | | ath.ethz.ch | | | | | | | | | 05/03/02 09:33 AM | | | | |---------+------------------------------> >---------------------------------------------------------------------------------------------------------------------| | | | To: r-help at stat.math.ethz.ch | | cc: | | Subject: [R] problems with rexp ? | >---------------------------------------------------------------------------------------------------------------------| Does anyone know if R have any problems with the exponential random number generation (function rexp)? I comment it because I executed data<-sort(rexp(100)) plot(data,dexp(data)/(1-pexp(data)),type="l") and the graphic isn't constant. (Note: exponential distribution have a constant hazard failure rate). Thank you, Juan -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._._._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 3 May 2002, Juan Ramon Gonzalez wrote:> Does anyone know if R have any problems with the exponential random number > generation (function rexp)? > > I comment it because I executed > > data<-sort(rexp(100)) > plot(data,dexp(data)/(1-pexp(data)),type="l") > > and the graphic isn't constant.Hi. Note that dexp(data)/(1-pexp(data)) is exactly (theoretically) 1 regardless of the values of 'data'. Thus, the nonconstant plot you're getting is solely due to roundoff (cancellation) error and gives no information about the distribution of the 'data' vector except that it contains some positive values for which the exponential density is very small. (Hence there's no indication of any problem with rexp). David Hunter Assistant Professor of Statistics Penn State University dhunter at stat.psu.edu (814) 863-0979 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._