[Distr-commits] r704 - in pkg/distr: R man tests/Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jan 4 19:58:20 CET 2011
Author: stamats
Date: 2011-01-04 19:58:19 +0100 (Tue, 04 Jan 2011)
New Revision: 704
Modified:
pkg/distr/R/internalUtils.R
pkg/distr/man/AbscontDistribution-class.Rd
pkg/distr/tests/Examples/distr-Ex.Rout.save
Log:
updated distr-Ex.Rout.save to R 2.12.1 patched, added a small modification to .makeDNew, small correction in example to AbscontDistribution-class
Modified: pkg/distr/R/internalUtils.R
===================================================================
--- pkg/distr/R/internalUtils.R 2011-01-04 14:44:50 UTC (rev 703)
+++ pkg/distr/R/internalUtils.R 2011-01-04 18:58:19 UTC (rev 704)
@@ -658,13 +658,18 @@
df1 <- mfun(x = x, y = dx1, yleft = 0, yright = 0)
if (standM == "sum")
- stand <- sum(dx)
- else {
- stand <- try(integrate(df1, -Inf, Inf)$value, TRUE)
- if (is(stand,"try-error")){
- warning("'integrate()' threw an error ---result may be inaccurate.")
- stand <- sum(df1(x))*h*(x[2]-x[1])
- }
+ stand <- sum(dx)
+ else{
+ stand <- try(integrate(df1, -Inf, Inf)$value, TRUE)
+ if (is(stand,"try-error")){
+ xm <- min(0.95*x,1.05*x) ## trick if x can be >0 or <0
+ xM <- max(0.95*x,1.05*x)
+ stand <- try(integrate(df1, xm, xM)$value, TRUE)
+ if (is(stand,"try-error")){
+ warning("'integrate()' threw an error ---result may be inaccurate.")
+ stand <- sum(df1(x))*h*(x[2]-x[1])
+ }
+ }
}
dfun <- function(x, log = FALSE)
{if (log)
Modified: pkg/distr/man/AbscontDistribution-class.Rd
===================================================================
--- pkg/distr/man/AbscontDistribution-class.Rd 2011-01-04 14:44:50 UTC (rev 703)
+++ pkg/distr/man/AbscontDistribution-class.Rd 2011-01-04 18:58:19 UTC (rev 704)
@@ -166,9 +166,9 @@
A2 <- A1*3 # a new absolutely continuous distributions with exact slots d, p, q
A3 <- N*0.9 + E*0.1 # a new absolutely continuous distribution with approximated slots d, p, q
r(A3)(1) # one random number generated from this distribution, e.g. -0.7150937
-d(A3)(0) # The (approximated) density for x=0 is 0.4379882.
-p(A3)(0) # The (approximated) probability that x <= 0 is 0.4562021.
-q(A3)(.1) # The (approximated) 10 percent quantile is 0.1.
+d(A3)(0) # The (approximated) density for x=0 is 0.43799.
+p(A3)(0) # The (approximated) probability that x <= 0 is 0.45620.
+q(A3)(.1) # The (approximated) 10 percent quantile is -1.06015.
}
\keyword{distribution}
\concept{absolutely continuous distribution}
Modified: pkg/distr/tests/Examples/distr-Ex.Rout.save
===================================================================
--- pkg/distr/tests/Examples/distr-Ex.Rout.save 2011-01-04 14:44:50 UTC (rev 703)
+++ pkg/distr/tests/Examples/distr-Ex.Rout.save 2011-01-04 18:58:19 UTC (rev 704)
@@ -1,7 +1,8 @@
-R version 2.10.1 Patched (2010-01-12 r50990)
-Copyright (C) 2010 The R Foundation for Statistical Computing
+R version 2.12.1 Patched (2011-01-03 r53910)
+Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
+Platform: x86_64-unknown-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
@@ -30,8 +31,7 @@
Loading required package: sfsmisc
Loading required package: SweaveListingUtils
:SweaveListingUtils> Utilities for Sweave together with
-:SweaveListingUtils> TeX listings package (version
-:SweaveListingUtils> 0.4.1)
+:SweaveListingUtils> TeX listings package (version 0.5)
:SweaveListingUtils>
:SweaveListingUtils> Some functions from package 'base'
:SweaveListingUtils> are intentionally masked ---see
@@ -52,14 +52,12 @@
Attaching package: 'SweaveListingUtils'
+The following object(s) are masked from 'package:base':
- The following object(s) are masked from package:base :
+ library, require
- library,
- require
-
-:distr> Object orientated implementation of distributions (version
-:distr> 2.2.1)
+:distr> Object oriented implementation of distributions (version
+:distr> 2.3)
:distr>
:distr> Attention: Arithmetics on distribution objects are
:distr> understood as operations on corresponding random variables
@@ -80,13 +78,10 @@
Attaching package: 'distr'
+The following object(s) are masked from 'package:stats':
- The following object(s) are masked from package:stats :
+ df, qqplot, sd
- df,
- qqplot,
- sd
-
>
> assign(".oldSearch", search(), pos = 'CheckExEnv')
> cleanEx()
@@ -105,6 +100,8 @@
> X <- Unif(2,3)
> Y <- Pois(lambda = 3)
> Z <- X+Y # generates Law of corresponding independent variables
+Warning in .makeDNew(x, dpn, h = 1, standM = "int") :
+ 'integrate()' threw an error ---result may be inaccurate.
> p(Z)(0.2)
[1] 0
> r(Z)(1000)
@@ -278,11 +275,11 @@
> A3 <- N*0.9 + E*0.1 # a new absolutely continuous distribution with approximated slots d, p, q
> r(A3)(1) # one random number generated from this distribution, e.g. -0.7150937
[1] -0.5492378
-> d(A3)(0) # The (approximated) density for x=0 is 0.4379882.
+> d(A3)(0) # The (approximated) density for x=0 is 0.43799.
[1] 0.4379965
-> p(A3)(0) # The (approximated) probability that x <= 0 is 0.4562021.
+> p(A3)(0) # The (approximated) probability that x <= 0 is 0.45620.
[1] 0.4561991
-> q(A3)(.1) # The (approximated) 10 percent quantile is 0.1.
+> q(A3)(.1) # The (approximated) 10 percent quantile is -1.06015.
[1] -1.060145
>
>
@@ -1353,7 +1350,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: Huberize-methods
-> ### Title: Methods for function Huberize in Package `distr'
+> ### Title: Methods for function Huberize in Package 'distr'
> ### Aliases: Huberize-methods Huberize Huberize,AcDcLcDistribution-method
> ### Keywords: distribution methods
>
@@ -1632,8 +1629,6 @@
see 'distrARITH()'; for switching off this warning see '?distroptions'
> plot(Hu)
> Hu0 <- makeAbscontDistribution(Hu)
-Warning in .makeDNew(xx, dx, h = NULL, Cont = TRUE, standM = "integrate") :
- 'integrate()' threw an error ---result may be inaccurate.
> Hu0
Distribution Object of Class: AbscontDistribution
Warning in function (object) :
@@ -1652,7 +1647,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: Minimum-methods
-> ### Title: Methods for functions Minimum and Maximum in Package `distr'
+> ### Title: Methods for functions Minimum and Maximum in Package 'distr'
> ### Aliases: Minimum-methods Minimum Maximum-methods Maximum
> ### Minimum,AbscontDistribution,AbscontDistribution-method
> ### Minimum,DiscreteDistribution,DiscreteDistribution-method
@@ -1981,8 +1976,6 @@
>
> rn2 <- function(n)ifelse(rbinom(n,1,0.3),rnorm(n)^2,rbinom(n,4,.3))
> x <- RtoDPQ.LC(r = rn2, e = 4, n = 512)
-Warning in .makeDNew(dxy$x, dxy$y, standM = "int") :
- 'integrate()' threw an error ---result may be inaccurate.
> plot(x)
> # returns density, cumulative distribution and quantile function of
> # squared standard normal distribution
@@ -2009,15 +2002,11 @@
>
> rn2 <- function(n){rnorm(n)^2}
> x <- RtoDPQ(r = rn2, e = 4, n = 512)
-Warning in .makeDNew(dxy$x, dxy$y, standM = "int") :
- 'integrate()' threw an error ---result may be inaccurate.
> # returns density, cumulative distribution and quantile function of
> # squared standard normal distribution
> x$dfun(4)
-[1] 0.02970112
+[1] 0.02970328
> RtoDPQ(r = rn2, e = 5, n = 1024) # for a better result
-Warning in .makeDNew(dxy$x, dxy$y, standM = "int") :
- 'integrate()' threw an error ---result may be inaccurate.
$dfun
function (x, log = FALSE)
{
@@ -2026,7 +2015,7 @@
else d0 <- df1(x)/stand
return(d0)
}
-<environment: 0x480b150>
+<environment: 0x38037a0>
$pfun
function (q, lower.tail = TRUE, log.p = FALSE)
@@ -2047,7 +2036,7 @@
else p0/nm
return(p0)
}
-<environment: 0x45f96d0>
+<environment: 0x3613b50>
$qfun
function (p, lower.tail = TRUE, log.p = FALSE)
@@ -2065,7 +2054,7 @@
else q.l(1 - p01)
return(as.numeric(q0))
}
-<environment: 0x3b80180>
+<environment: 0x49fad40>
>
> rp2 <- function(n){rpois(n, lambda = 1)^2}
@@ -2091,16 +2080,12 @@
>
> rn2 <- function(n){rnorm(n)^2}
> x <- RtoDPQ(r = rn2, e = 4, n = 512)
-Warning in .makeDNew(dxy$x, dxy$y, standM = "int") :
- 'integrate()' threw an error ---result may be inaccurate.
> # returns density, cumulative distribution and quantile function of
> # squared standard normal distribution
>
> x$dfun(4)
-[1] 0.02970112
+[1] 0.02970328
> RtoDPQ(r = rn2, e = 5, n = 1024) # for a better result
-Warning in .makeDNew(dxy$x, dxy$y, standM = "int") :
- 'integrate()' threw an error ---result may be inaccurate.
$dfun
function (x, log = FALSE)
{
@@ -2109,7 +2094,7 @@
else d0 <- df1(x)/stand
return(d0)
}
-<environment: 0x4baa228>
+<environment: 0x3582cc8>
$pfun
function (q, lower.tail = TRUE, log.p = FALSE)
@@ -2130,7 +2115,7 @@
else p0/nm
return(p0)
}
-<environment: 0x51643e8>
+<environment: 0x537ad98>
$qfun
function (p, lower.tail = TRUE, log.p = FALSE)
@@ -2148,7 +2133,7 @@
else q.l(1 - p01)
return(as.numeric(q0))
}
-<environment: 0x5348ac0>
+<environment: 0x49f5ce8>
>
> rp2 <- function(n){rpois(n, lambda = 1)^2}
@@ -2266,7 +2251,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: Truncate-methods
-> ### Title: Methods for function Truncate in Package `distr'
+> ### Title: Methods for function Truncate in Package 'distr'
> ### Aliases: Truncate-methods Truncate Truncate,AbscontDistribution-method
> ### Truncate,DiscreteDistribution-method
> ### Truncate,LatticeDistribution-method
@@ -2698,7 +2683,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: decomposePM-methods
-> ### Title: Methods for function decomposePM in Package `distr'
+> ### Title: Methods for function decomposePM in Package 'distr'
> ### Aliases: decomposePM-methods decomposePM
> ### decomposePM,AbscontDistribution-method
> ### decomposePM,DiscreteDistribution-method
@@ -2953,7 +2938,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: distroptions
-> ### Title: functions to change the global variables of the package `distr'
+> ### Title: functions to change the global variables of the package 'distr'
> ### Aliases: distroptions getdistrOption DefaultNrGridPoints
> ### DistrResolution DistrCollapse TruncQuantile WarningSim WarningArith
> ### DefaultNrFFTGridPointsExponent RtoDPQ.e WarningArith WarningSim
@@ -3132,6 +3117,24 @@
>
>
> cleanEx()
+> nameEx("igamma")
+> ### * igamma
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: igamma
+> ### Title: Inverse of the digamma function
+> ### Aliases: igamma
+> ### Keywords: math
+>
+> ### ** Examples
+>
+> igamma(digamma(c(1e-4,1,20,1e8)))
+[1] 1.000000e-04 1.000000e+00 2.099929e+01 1.734795e+09
+>
+>
+>
+> cleanEx()
> nameEx("liesInSupport")
> ### * liesInSupport
>
@@ -3335,7 +3338,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: options
-> ### Title: additional options in package `distr'
+> ### Title: additional options in package 'distr'
> ### Aliases: options newDevice
> ### Keywords: environment iplot dplot
>
@@ -3354,7 +3357,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: plot-methods
-> ### Title: Methods for Function plot in Package `distr'
+> ### Title: Methods for Function plot in Package 'distr'
> ### Aliases: plot plot-methods
> ### plot,AffLinUnivarLebDecDistribution,missing-method
> ### plot,UnivarLebDecDistribution,missing-method
@@ -3613,7 +3616,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: qqplot
-> ### Title: Methods for Function qqplot in Package `distr'
+> ### Title: Methods for Function qqplot in Package 'distr'
> ### Aliases: qqplot qqplot-methods qqplot,ANY,ANY-method
> ### qqplot,UnivariateDistribution,UnivariateDistribution-method
> ### Keywords: hplot distribution
@@ -3762,7 +3765,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: simplifyD-methods
-> ### Title: Methods for function simplifyD in Package `distr'
+> ### Title: Methods for function simplifyD in Package 'distr'
> ### Aliases: simplifyD-methods simplifyD
> ### simplifyD,AbscontDistribution-method
> ### simplifyD,DiscreteDistribution-method
@@ -3849,7 +3852,7 @@
> flush(stderr()); flush(stdout())
>
> ### Name: simplifyr-methods
-> ### Title: Methods for Function simplifyr in Package `distr'
+> ### Title: Methods for Function simplifyr in Package 'distr'
> ### Aliases: simplifyr-methods simplifyr
> ### simplifyr,UnivariateDistribution-method
> ### Keywords: math distribution arith
@@ -3859,11 +3862,11 @@
> F <- ( Norm() + Binom() + Pois() + Exp() ) * 2 - 10
> system.time(r(F)(10^6))
user system elapsed
- 0.790 0.040 0.836
+ 0.750 0.040 0.783
> simplifyr(F, size = 10^6)
> system.time(r(F)(10^6))
user system elapsed
- 0.040 0.000 0.043
+ 0.040 0.000 0.038
>
>
> cleanEx()
@@ -3897,7 +3900,7 @@
> ### * <FOOTER>
> ###
> cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 154.42 0.39 154.85 0.02 0.02
+Time elapsed: 144.17 0.28 144.939 0 0
> grDevices::dev.off()
postscript
2
More information about the Distr-commits
mailing list