[Distr-commits] r607 - in branches/distr-2.2/pkg/distrEx: . tests tests/Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Oct 16 05:41:14 CEST 2009
Author: stamats
Date: 2009-10-16 05:41:14 +0200 (Fri, 16 Oct 2009)
New Revision: 607
Added:
branches/distr-2.2/pkg/distrEx/tests/
branches/distr-2.2/pkg/distrEx/tests/Examples/
branches/distr-2.2/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save
Log:
added *-Ex.Rout.save to new tests/Examples folder. We will have to check and probably to slightly modify these files with every new R version.
Added: branches/distr-2.2/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save
===================================================================
--- branches/distr-2.2/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save (rev 0)
+++ branches/distr-2.2/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save 2009-10-16 03:41:14 UTC (rev 607)
@@ -0,0 +1,1927 @@
+
+R version 2.10.0 beta (2009-10-15 r50107)
+Copyright (C) 2009 The R Foundation for Statistical Computing
+ISBN 3-900051-07-0
+
+R is free software and comes with ABSOLUTELY NO WARRANTY.
+You are welcome to redistribute it under certain conditions.
+Type 'license()' or 'licence()' for distribution details.
+
+ Natural language support but running in an English locale
+
+R is a collaborative project with many contributors.
+Type 'contributors()' for more information and
+'citation()' on how to cite R or R packages in publications.
+
+Type 'demo()' for some demos, 'help()' for on-line help, or
+'help.start()' for an HTML browser interface to help.
+Type 'q()' to quit R.
+
+> ### * <HEADER>
+> ###
+> attach(NULL, name = "CheckExEnv")
+> assign("nameEx",
++ local({
++ s <- "__{must remake R-ex/*.R}__"
++ function(new) {
++ if(!missing(new)) s <<- new else s
++ }
++ }),
++ pos = "CheckExEnv")
+> ## Add some hooks to label plot pages for base and grid graphics
+> assign("base_plot_hook",
++ function() {
++ pp <- par(c("mfg","mfcol","oma","mar"))
++ if(all(pp$mfg[1:2] == c(1, pp$mfcol[2]))) {
++ outer <- (oma4 <- pp$oma[4]) > 0; mar4 <- pp$mar[4]
++ mtext(sprintf("help(\"%s\")", nameEx()), side = 4,
++ line = if(outer)max(1, oma4 - 1) else min(1, mar4 - 1),
++ outer = outer, adj = 1, cex = .8, col = "orchid", las=3)
++ }
++ },
++ pos = "CheckExEnv")
+> assign("grid_plot_hook",
++ function() {
++ grid::pushViewport(grid::viewport(width=grid::unit(1, "npc") -
++ grid::unit(1, "lines"), x=0, just="left"))
++ grid::grid.text(sprintf("help(\"%s\")", nameEx()),
++ x=grid::unit(1, "npc") + grid::unit(0.5, "lines"),
++ y=grid::unit(0.8, "npc"), rot=90,
++ gp=grid::gpar(col="orchid"))
++ },
++ pos = "CheckExEnv")
+> setHook("plot.new", get("base_plot_hook", pos = "CheckExEnv"))
+> setHook("persp", get("base_plot_hook", pos = "CheckExEnv"))
+> setHook("grid.newpage", get("grid_plot_hook", pos = "CheckExEnv"))
+> assign("cleanEx",
++ function(env = .GlobalEnv) {
++ rm(list = ls(envir = env, all.names = TRUE), envir = env)
++ RNGkind("default", "default")
++ set.seed(1)
++ options(warn = 1)
++ .CheckExEnv <- as.environment("CheckExEnv")
++ delayedAssign("T", stop("T used instead of TRUE"),
++ assign.env = .CheckExEnv)
++ delayedAssign("F", stop("F used instead of FALSE"),
++ assign.env = .CheckExEnv)
++ sch <- search()
++ newitems <- sch[! sch %in% .oldSearch]
++ for(item in rev(newitems))
++ eval(substitute(detach(item), list(item=item)))
++ missitems <- .oldSearch[! .oldSearch %in% sch]
++ if(length(missitems))
++ warning("items ", paste(missitems, collapse=", "),
++ " have been removed from the search path")
++ },
++ pos = "CheckExEnv")
+> assign("ptime", proc.time(), pos = "CheckExEnv")
+> ## at least one package changes these via ps.options(), so do this
+> ## before loading the package.
+> ## Use postscript as incomplete files may be viewable, unlike PDF.
+> ## Choose a size that is close to on-screen devices, fix paper
+> grDevices::ps.options(width = 7, height = 7, paper = "a4", reset = TRUE)
+> grDevices::postscript("distrEx-Ex.ps")
+>
+> assign("par.postscript", graphics::par(no.readonly = TRUE), pos = "CheckExEnv")
+> options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly"))
+> options(warn = 1)
+> library('distrEx')
+Loading required package: distr
+Loading required package: startupmsg
+:startupmsg> Utilities for start-up messages (version 0.7)
+:startupmsg>
+:startupmsg> For more information see ?"startupmsg",
+:startupmsg> NEWS("startupmsg")
+
+Loading required package: sfsmisc
+Loading required package: SweaveListingUtils
+:SweaveListingUtils> Utilities for Sweave together with
+:SweaveListingUtils> TeX listings package (version 0.4)
+:SweaveListingUtils>
+:SweaveListingUtils> Some functions from package 'base'
+:SweaveListingUtils> are intentionally masked ---see
+:SweaveListingUtils> SweaveListingMASK().
+:SweaveListingUtils>
+:SweaveListingUtils> Note that global options are
+:SweaveListingUtils> controlled by
+:SweaveListingUtils> SweaveListingoptions() ---c.f.
+:SweaveListingUtils> ?"SweaveListingoptions".
+:SweaveListingUtils>
+:SweaveListingUtils> For more information see
+:SweaveListingUtils> ?"SweaveListingUtils",
+:SweaveListingUtils> NEWS("SweaveListingUtils")
+:SweaveListingUtils> There is a vignette to this
+:SweaveListingUtils> package; try
+:SweaveListingUtils> vignette("ExampleSweaveListingUtils").
+
+
+Attaching package: 'SweaveListingUtils'
+
+
+ The following object(s) are masked from package:base :
+
+ library,
+ require
+
+:distr> Object orientated implementation of distributions (version
+:distr> 2.2)
+:distr>
+:distr> Attention: Arithmetics on distribution objects are
+:distr> understood as operations on corresponding random variables
+:distr> (r.v.s); see distrARITH().
+:distr>
+:distr> Some functions from package 'stats' are intentionally masked
+:distr> ---see distrMASK().
+:distr>
+:distr> Note that global options are controlled by distroptions()
+:distr> ---c.f. ?"distroptions".
+:distr>
+:distr> For more information see ?"distr", NEWS("distr"), as well as
+:distr> http://distr.r-forge.r-project.org/
+:distr> Package "distrDoc" provides a vignette to this package as
+:distr> well as to several extension packages; try
+:distr> vignette("distr").
+
+
+Attaching package: 'distr'
+
+
+ The following object(s) are masked from package:stats :
+
+ df,
+ qqplot,
+ sd
+
+Loading required package: evd
+Loading required package: actuar
+
+Attaching package: 'actuar'
+
+
+ The following object(s) are masked from package:grDevices :
+
+ cm
+
+:distrEx> Extensions of package distr (version 2.2)
+:distrEx>
+:distrEx> Note: Packages "e1071", "moments", "fBasics" should be
+:distrEx> attached /before/ package "distrEx". See distrExMASK().
+:distrEx>
+:distrEx> For more information see ?"distrEx", NEWS("distrEx"), as
+:distrEx> well as
+:distrEx> http://distr.r-forge.r-project.org/
+:distrEx> Package "distrDoc" provides a vignette to this package
+:distrEx> as well as to several related packages; try
+:distrEx> vignette("distr").
+
+
+Attaching package: 'distrEx'
+
+
+ The following object(s) are masked from package:stats :
+
+ IQR,
+ mad,
+ median,
+ var
+
+>
+> assign(".oldSearch", search(), pos = 'CheckExEnv')
+> assign(".oldNS", loadedNamespaces(), pos = 'CheckExEnv')
+> cleanEx(); nameEx("AbscontCondDistribution-class")
+> ### * AbscontCondDistribution-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: AbscontCondDistribution-class
+> ### Title: Absolutely continuous conditional distribution
+> ### Aliases: AbscontCondDistribution-class
+> ### Keywords: distribution
+>
+> ### ** Examples
+> new("AbscontCondDistribution")
+Distribution object of class: AbscontCondDistribution
+## cond:
+An object of class “Condition”
+Slot "name":
+[1] "a condition"
+
+>
+>
+> cleanEx(); nameEx("AsymTotalVarDist")
+> ### * AsymTotalVarDist
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: AsymTotalVarDist
+> ### Title: Generic function for the computation of asymmetric total
+> ### variation distance of two distributions
+> ### Aliases: AsymTotalVarDist AsymTotalVarDist-methods
+> ### AsymTotalVarDist,AbscontDistribution,AbscontDistribution-method
+> ### AsymTotalVarDist,AbscontDistribution,DiscreteDistribution-method
+> ### AsymTotalVarDist,DiscreteDistribution,DiscreteDistribution-method
+> ### AsymTotalVarDist,DiscreteDistribution,AbscontDistribution-method
+> ### AsymTotalVarDist,LatticeDistribution,DiscreteDistribution-method
+> ### AsymTotalVarDist,DiscreteDistribution,LatticeDistribution-method
+> ### AsymTotalVarDist,LatticeDistribution,LatticeDistribution-method
+> ### AsymTotalVarDist,numeric,DiscreteDistribution-method
+> ### AsymTotalVarDist,DiscreteDistribution,numeric-method
+> ### AsymTotalVarDist,numeric,AbscontDistribution-method
+> ### AsymTotalVarDist,AbscontDistribution,numeric-method
+> ### AsymTotalVarDist,AcDcLcDistribution,AcDcLcDistribution-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> AsymTotalVarDist(Norm(), Gumbel(), rho=0.3)
+asym. total variation distance
+ 0.2316870
+> AsymTotalVarDist(Norm(), Td(10), rho=0.3)
+asym. total variation distance
+ 0.03412602
+> AsymTotalVarDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100), rho=0.3) # mutually singular
+asym. total variation distance
+ 1
+> AsymTotalVarDist(Pois(10), Binom(size = 20), rho=0.3)
+asym. total variation distance
+ 0.3093959
+>
+> x <- rnorm(100)
+> AsymTotalVarDist(Norm(), x, rho=0.3)
+asym. total variation distance
+ 0.3140162
+> AsymTotalVarDist(x, Norm(), asis.smooth.discretize = "smooth", rho=0.3)
+asym. total variation distance
+ 0.2658876
+>
+> y <- (rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5)
+> AsymTotalVarDist(y, Norm(), rho=0.3)
+asym. total variation distance
+ 0.8343428
+> AsymTotalVarDist(y, Norm(), asis.smooth.discretize = "smooth", rho=0.3)
+asym. total variation distance
+ 0.6326863
+>
+> AsymTotalVarDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5), rho=0.3)
+asym. total variation distance
+ 0.2925150
+>
+>
+>
+> cleanEx(); nameEx("Condition-class")
+> ### * Condition-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: Condition-class
+> ### Title: Conditions
+> ### Aliases: Condition-class name,Condition-method name<-,Condition-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+> new("Condition")
+An object of class “Condition”
+Slot "name":
+[1] "a condition"
+
+>
+>
+> cleanEx(); nameEx("ContaminationSize")
+> ### * ContaminationSize
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: ContaminationSize
+> ### Title: Generic Function for the Computation of the Convex Contamination
+> ### (Pseudo-)Distance of Two Distributions
+> ### Aliases: ContaminationSize ContaminationSize-methods
+> ### ContaminationSize,AbscontDistribution,AbscontDistribution-method
+> ### ContaminationSize,DiscreteDistribution,DiscreteDistribution-method
+> ### ContaminationSize,LatticeDistribution,DiscreteDistribution-method
+> ### ContaminationSize,DiscreteDistribution,LatticeDistribution-method
+> ### ContaminationSize,LatticeDistribution,LatticeDistribution-method
+> ### ContaminationSize,AcDcLcDistribution,AcDcLcDistribution-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> ContaminationSize(Norm(), Norm(mean=0.1))
+$e1
+Distribution Object of Class: Norm
+ mean: 0
+ sd: 1
+
+$e2
+Distribution Object of Class: Norm
+ mean: 0.1
+ sd: 1
+
+$size.of.contamination
+[1] 0.3504588
+
+> ContaminationSize(Pois(), Pois(1.5))
+$e1
+Distribution Object of Class: Pois
+ lambda: 1
+
+$e2
+Distribution Object of Class: Pois
+ lambda: 1.5
+
+$size.of.contamination
+[1] 0.3934693
+
+>
+>
+>
+> cleanEx(); nameEx("ConvexContamination")
+> ### * ConvexContamination
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: ConvexContamination
+> ### Title: Generic Function for Generating Convex Contaminations
+> ### Aliases: ConvexContamination ConvexContamination-methods
+> ### ConvexContamination,UnivariateDistribution,UnivariateDistribution,numeric-method
+> ### ConvexContamination,AbscontDistribution,AbscontDistribution,numeric-method
+> ### ConvexContamination,AbscontDistribution,UnivariateDistribution,numeric-method
+> ### ConvexContamination,DiscreteDistribution,DiscreteDistribution,numeric-method
+> ### ConvexContamination,LatticeDistribution,DiscreteDistribution,numeric-method
+> ### ConvexContamination,DiscreteDistribution,LatticeDistribution,numeric-method
+> ### ConvexContamination,LatticeDistribution,LatticeDistribution,numeric-method
+> ### ConvexContamination,AcDcLcDistribution,AcDcLcDistribution,numeric-method
+> ### Keywords: distribution methods
+>
+> ### ** Examples
+>
+> # Convex combination of two normal distributions
+> C1 <- ConvexContamination(e1 = Norm(), e2 = Norm(mean = 5), size = 0.1)
+> plot(C1)
+>
+>
+>
+> cleanEx(); nameEx("CvMDist")
+> ### * CvMDist
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: CvMDist
+> ### Title: Generic function for the computation of the Cramer - von Mises
+> ### distance of two distributions
+> ### Aliases: CvMDist CvMDist-methods
+> ### CvMDist,UnivariateDistribution,UnivariateDistribution-method
+> ### CvMDist,numeric,UnivariateDistribution-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> CvMDist(Norm(), Gumbel())
+CvM distance
+ 0.1227136
+> CvMDist(Norm(), Gumbel(), mu = Norm())
+CvM distance
+ 0.1227136
+> CvMDist(Norm(), Td(10))
+CvM distance
+ 0.00933072
+> CvMDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100))
+CvM distance
+ 0.03027538
+> CvMDist(Pois(10), Binom(size = 20))
+CvM distance
+ 0.06084579
+> CvMDist(rnorm(100),Norm())
+CvM distance
+ 0.04673208
+> CvMDist((rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5), Norm())
+CvM distance
+ 0.07266983
+> CvMDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5))
+CvM distance
+ 0.1205683
+> CvMDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5), mu = Pois())
+CvM distance
+ 0.001969063
+>
+>
+>
+> cleanEx(); nameEx("DiscreteCondDistribution-class")
+> ### * DiscreteCondDistribution-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: DiscreteCondDistribution-class
+> ### Title: Discrete conditional distribution
+> ### Aliases: DiscreteCondDistribution-class
+> ### Keywords: distribution
+>
+> ### ** Examples
+> new("DiscreteCondDistribution")
+Distribution object of class: DiscreteCondDistribution
+## cond:
+An object of class “Condition”
+Slot "name":
+[1] "a condition"
+
+>
+>
+> cleanEx(); nameEx("DiscreteMVDistribution-class")
+> ### * DiscreteMVDistribution-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: DiscreteMVDistribution-class
+> ### Title: Discrete Multivariate Distributions
+> ### Aliases: DiscreteMVDistribution-class
+> ### support,DiscreteMVDistribution-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> (D1 <- new("MultivariateDistribution")) # Dirac measure in (0,0)
+> r(D1)(5)
+ [,1] [,2]
+[1,] 0 0
+[2,] 0 0
+[3,] 0 0
+[4,] 0 0
+[5,] 0 0
+>
+> (D2 <- DiscreteMVDistribution(supp = matrix(c(1:5, rep(3, 5)), ncol=2, byrow=TRUE)))
+Warning in DiscreteMVDistribution(supp = matrix(c(1:5, rep(3, 5)), ncol = 2, :
+ collapsing to unique support values
+> support(D2)
+ [,1] [,2]
+[1,] 1 2
+[2,] 3 4
+[3,] 5 3
+[4,] 3 3
+> r(D2)(10)
+ [,1] [,2]
+ [1,] 3 3
+ [2,] 3 3
+ [3,] 5 3
+ [4,] 1 2
+ [5,] 3 3
+ [6,] 1 2
+ [7,] 1 2
+ [8,] 3 4
+ [9,] 3 4
+[10,] 3 3
+> d(D2)(support(D2))
+[1] 0.2 0.2 0.2 0.4
+> p(D2)(lower = c(1,1), upper = c(3,3))
+[1] 0.6
+> q(D2)
+NULL
+> param(D2)
+NULL
+> img(D2)
+An object of class “EuclideanSpace”
+Slot "dimension":
+[1] 2
+
+Slot "name":
+[1] "Euclidean Space"
+
+>
+> e1 <- E(D2) # expectation
+>
+>
+>
+> cleanEx(); nameEx("DiscreteMVDistribution")
+> ### * DiscreteMVDistribution
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: DiscreteMVDistribution
+> ### Title: Generating function for DiscreteMVDistribution-class
+> ### Aliases: DiscreteMVDistribution
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> # Dirac-measure at (0,0,0)
+> D1 <- DiscreteMVDistribution(supp = c(0,0,0))
+> support(D1)
+ [,1] [,2] [,3]
+[1,] 0 0 0
+>
+> # simple discrete distribution
+> D2 <- DiscreteMVDistribution(supp = matrix(c(0,1,0,2,2,1,1,0), ncol=2),
++ prob = c(0.3, 0.2, 0.2, 0.3))
+> support(D2)
+ [,1] [,2]
+[1,] 0 2
+[2,] 1 1
+[3,] 0 1
+[4,] 2 0
+> r(D2)(10)
+ [,1] [,2]
+ [1,] 0 2
+ [2,] 2 0
+ [3,] 2 0
+ [4,] 1 1
+ [5,] 0 2
+ [6,] 1 1
+ [7,] 1 1
+ [8,] 0 1
+ [9,] 0 1
+[10,] 0 2
+>
+>
+>
+> cleanEx(); nameEx("E")
+> ### * E
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: E
+> ### Title: Generic Function for the Computation of (Conditional)
+> ### Expectations
+> ### Aliases: E E-methods E,UnivariateDistribution,missing,missing-method
+> ### E,AbscontDistribution,missing,missing-method
+> ### E,DiscreteDistribution,missing,missing-method
+> ### E,LatticeDistribution,missing,missing-method
+> ### E,AffLinDistribution,missing,missing-method
+> ### E,AffLinAbscontDistribution,missing,missing-method
+> ### E,AffLinDiscreteDistribution,missing,missing-method
+> ### E,AffLinLatticeDistribution,missing,missing-method
+> ### E,MultivariateDistribution,missing,missing-method
+> ### E,DiscreteMVDistribution,missing,missing-method
+> ### E,UnivarLebDecDistribution,missing,missing-method
+> ### E,AffLinUnivarLebDecDistribution,missing,missing-method
+> ### E,UnivarMixingDistribution,missing,missing-method
+> ### E,UnivariateDistribution,function,missing-method
+> ### E,AbscontDistribution,function,missing-method
+> ### E,DiscreteDistribution,function,missing-method
+> ### E,LatticeDistribution,function,missing-method
+> ### E,MultivariateDistribution,function,missing-method
+> ### E,DiscreteMVDistribution,function,missing-method
+> ### E,UnivarLebDecDistribution,function,missing-method
+> ### E,UnivarMixingDistribution,function,missing-method
+> ### E,AcDcLcDistribution,ANY,ANY-method
+> ### E,CompoundDistribution,missing,missing-method
+> ### E,UnivariateCondDistribution,missing,numeric-method
+> ### E,AbscontCondDistribution,missing,numeric-method
+> ### E,DiscreteCondDistribution,missing,numeric-method
+> ### E,UnivarLebDecDistribution,missing,ANY-method
+> ### E,UnivarMixingDistribution,missing,ANY-method
+> ### E,UnivarLebDecDistribution,function,ANY-method
+> ### E,UnivariateCondDistribution,function,numeric-method
+> ### E,UnivarMixingDistribution,function,ANY-method
+> ### E,AbscontCondDistribution,function,numeric-method
+> ### E,DiscreteCondDistribution,function,numeric-method
+> ### E,Arcsine,missing,missing-method E,Beta,missing,missing-method
+> ### E,Binom,missing,missing-method E,Cauchy,missing,missing-method
+> ### E,Chisq,missing,missing-method E,Dirac,missing,missing-method
+> ### E,DExp,missing,missing-method E,Exp,missing,missing-method
+> ### E,Fd,missing,missing-method E,Gammad,missing,missing-method
+> ### E,Gammad,function,missing-method E,Geom,missing,missing-method
+> ### E,Gumbel,missing,missing-method E,GPareto,missing,missing-method
+> ### E,GPareto,function,missing-method E,Hyper,missing,missing-method
+> ### E,Logis,missing,missing-method E,Lnorm,missing,missing-method
+> ### E,Nbinom,missing,missing-method E,Norm,missing,missing-method
+> ### E,Pareto,missing,missing-method E,Pois,missing,missing-method
+> ### E,Td,missing,missing-method E,Unif,missing,missing-method
+> ### E,Weibull,missing,missing-method
+> ### Keywords: methods distribution
+>
+> ### ** Examples
+>
+> # mean of Exp(1) distribution
+> E <- Exp()
+>
+> E(E) ## uses explicit terms
+[1] 1
+> E(as(E,"AbscontDistribution")) ## uses numerical integration
+[1] 0.9999983
+> E(as(E,"UnivariateDistribution")) ## uses simulations
+[1] 1.002698
+> E(E, fun = function(x){2*x^2}) ## uses simulations
+[1] 3.999941
+>
+> # the same operator for discrete distributions:
+> P <- Pois(lambda=2)
+>
+> E(P) ## uses explicit terms
+[1] 2
+> E(as(P,"DiscreteDistribution")) ## uses sums
+[1] 1.999997
+> E(as(P,"UnivariateDistribution")) ## uses simulations
+[1] 2.00881
+> E(P, fun = function(x){2*x^2}) ## uses simulations
+[1] 11.99993
+>
+>
+> # second moment of N(1,4)
+> E(Norm(mean=1, sd=2), fun = function(x){x^2})
+[1] 4.999977
+> E(Norm(mean=1, sd=2), fun = function(x){x^2}, useApply = FALSE)
+[1] 4.999977
+>
+> # conditional distribution of a linear model
+> D1 <- LMCondDistribution(theta = 1)
+> E(D1, cond = 1)
+[1] 0.9999998
+> E(Norm(mean=1))
+[1] 1
+> E(D1, function(x){x^2}, cond = 1)
+[1] 1.999994
+> E(Norm(mean=1), fun = function(x){x^2})
+[1] 1.999994
+> E(D1, function(x, cond){cond*x^2}, cond = 2, withCond = TRUE, useApply = FALSE)
+[1] 9.999987
+> E(Norm(mean=2), function(x){2*x^2})
+[1] 9.999987
+>
+> E(as(Norm(mean=2),"AbscontDistribution"))
+[1] 2
+> ### somewhat less accurate:
+> E(as(Norm(mean=2),"AbscontDistribution"),
++ lowerTruncQuantil=1e-4,upperTruncQuantil=1e-4, IQR.fac= 4)
+[1] 2
+> ### even less accurate:
+> E(as(Norm(mean=2),"AbscontDistribution"),
++ lowerTruncQuantil=1e-2,upperTruncQuantil=1e-2, IQR.fac= 4)
+[1] 2
+> ### no good idea, but just as an example:
+> E(as(Norm(mean=2),"AbscontDistribution"),
++ lowerTruncQuantil=1e-2,upperTruncQuantil=1e-2, IQR.fac= .1)
+[1] 2
+>
+> ### truncation of integration range; see also m1df...
+> E(Norm(mean=2), low=2,upp=4)
+[1] 1.299451
+>
+> E(Cauchy())
+[1] NA
+> E(Cauchy(),upp=3,low=-2)
+[1] 0
+> # some Lebesgue decomposed distribution
+> mymix <- UnivarLebDecDistribution(acPart = Norm(), discretePart = Binom(4,.4),
++ acWeight = 0.4)
+> E(mymix)
+[1] 0.96
+>
+>
+>
+> cleanEx(); nameEx("EuclCondition-class")
+> ### * EuclCondition-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: EuclCondition-class
+> ### Title: Conditioning by an Euclidean space.
+> ### Aliases: EuclCondition-class Range Range,EuclCondition-method
+> ### show,EuclCondition-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> new("EuclCondition")
+name: conditioning by an Euclidean space
+Range: Euclidean Space with dimension 1
+>
+>
+>
+> cleanEx(); nameEx("EuclCondition")
+> ### * EuclCondition
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: EuclCondition
+> ### Title: Generating function for EuclCondition-class
+> ### Aliases: EuclCondition
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> EuclCondition(dimension = 3)
+name: conditioning by an Euclidean space
+Range: Euclidean Space with dimension 3
+>
+> ## The function is currently defined as
+> function(dimension){
++ new("EuclCondition", Range = EuclideanSpace(dimension = dimension))
++ }
+function (dimension)
+{
+ new("EuclCondition", Range = EuclideanSpace(dimension = dimension))
+}
+>
+>
+>
+> cleanEx(); nameEx("GLIntegrate")
+> ### * GLIntegrate
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: GLIntegrate
+> ### Title: Gauss-Legendre Quadrature
+> ### Aliases: GLIntegrate
+> ### Keywords: math utilities
+>
+> ### ** Examples
+>
+> integrate(dnorm, -1.96, 1.96)
+0.9500042 with absolute error < 1.0e-11
+> GLIntegrate(dnorm, -1.96, 1.96)
+[1] 0.9500042
+>
+>
+>
+> cleanEx(); nameEx("GPareto-class")
+> ### * GPareto-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: GPareto-class
+> ### Title: Generalized Pareto distribution
+> ### Aliases: GPareto-class initialize,GPareto-method loc,GPareto-method
+> ### loc<-,GPareto-method location,GPareto-method
+> ### location<-,GPareto-method scale,GPareto-method scale<-,GPareto-method
+> ### shape,GPareto-method shape<-,GPareto-method +,GPareto,numeric-method
+> ### *,GPareto,numeric-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> (P1 <- new("GPareto", loc = 0, scale = 1,shape = 0))
+Distribution Object of Class: GPareto
+ loc: 0
+ scale: 1
+ shape: 0
+> plot(P1)
+> shape(P1)
+[1] 0
+> loc(P1)
+[1] 0
+> scale(P1) <- 4
+> loc(P1) <- 2
+> plot(P1)
+>
+>
+>
+> cleanEx(); nameEx("GPareto")
+> ### * GPareto
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: GPareto
+> ### Title: Generating function for GPareto-class
+> ### Aliases: GPareto
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> (P1 <- GPareto(loc = 0, scale = 1, shape = 0))
+Distribution Object of Class: Exp
+ rate: 1
+> plot(P1)
+>
+> E(GPareto())
+[1] 1
+> E(P1, function(x){x^2})
+[1] 1.999971
+>
+>
+>
+>
+> cleanEx(); nameEx("GParetoParameter-class")
+> ### * GParetoParameter-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: GParetoParameter-class
+> ### Title: Parameter of generalized Pareto distributions
+> ### Aliases: GParetoParameter-class loc,GParetoParameter-method
+> ### loc<-,GParetoParameter-method location,GParetoParameter-method
+> ### location<-,GParetoParameter-method scale,GParetoParameter-method
+> ### scale<-,GParetoParameter-method shape,GParetoParameter-method
+> ### shape<-,GParetoParameter-method
+> ### Keywords: distribution models
+>
+> ### ** Examples
+>
+> new("GParetoParameter")
+An object of class “GParetoParameter”
+Slot "loc":
+[1] 0
+
+Slot "scale":
+[1] 1
+
+Slot "shape":
+[1] 0
+
+Slot "name":
+[1] "Parameter of a generalized Pareto distribution"
+
+>
+>
+>
+> cleanEx(); nameEx("Gumbel-class")
+> ### * Gumbel-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: Gumbel-class
+> ### Title: Gumbel distribution
+> ### Aliases: Gumbel-class initialize,Gumbel-method loc,Gumbel-method
+> ### loc<-,Gumbel-method scale,Gumbel-method scale<-,Gumbel-method
+> ### +,Gumbel,numeric-method *,Gumbel,numeric-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> (G1 <- new("Gumbel", loc = 1, scale = 2))
+Distribution Object of Class: Gumbel
+ loc: 1
+ scale: 2
+> plot(G1)
+> loc(G1)
+[1] 1
+> scale(G1)
+[1] 2
+> loc(G1) <- -1
+> scale(G1) <- 2
+> plot(G1)
+>
+>
+>
+> cleanEx(); nameEx("Gumbel")
+> ### * Gumbel
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: Gumbel
+> ### Title: Generating function for Gumbel-class
+> ### Aliases: Gumbel
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> (G1 <- Gumbel(loc = 1, scale = 2))
+Distribution Object of Class: Gumbel
+ loc: 1
+ scale: 2
+> plot(G1)
+> loc(G1)
+[1] 1
+> scale(G1)
+[1] 2
+> loc(G1) <- -1
+> scale(G1) <- 2
+> plot(G1)
+>
+> E(Gumbel()) # Euler's constant
+[1] -0.5772157
+> E(G1, function(x){x^2})
+[1] 6.60347
+>
+> ## The function is currently defined as
+> function(loc = 0, scale = 1){
++ new("Gumbel", loc = loc, scale = scale)
++ }
+function (loc = 0, scale = 1)
+{
+ new("Gumbel", loc = loc, scale = scale)
+}
+>
+>
+>
+> cleanEx(); nameEx("GumbelParameter-class")
+> ### * GumbelParameter-class
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: GumbelParameter-class
+> ### Title: Paramter of Gumbel distributions
+> ### Aliases: GumbelParameter-class loc loc,GumbelParameter-method loc<-
+> ### loc<-,GumbelParameter-method scale,GumbelParameter-method
+> ### scale<-,GumbelParameter-method
+> ### Keywords: distribution models
+>
+> ### ** Examples
+>
+> new("GumbelParameter")
+An object of class “GumbelParameter”
+Slot "loc":
+[1] 0
+
+Slot "scale":
+[1] 1
+
+Slot "name":
+[1] "parameter of a Gumbel distribution"
+
+>
+>
+>
+> cleanEx(); nameEx("HellingerDist")
+> ### * HellingerDist
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: HellingerDist
+> ### Title: Generic function for the computation of the Hellinger distance
+> ### of two distributions
+> ### Aliases: HellingerDist HellingerDist-methods
+> ### HellingerDist,AbscontDistribution,AbscontDistribution-method
+> ### HellingerDist,AbscontDistribution,DiscreteDistribution-method
+> ### HellingerDist,DiscreteDistribution,DiscreteDistribution-method
+> ### HellingerDist,DiscreteDistribution,AbscontDistribution-method
+> ### HellingerDist,LatticeDistribution,DiscreteDistribution-method
+> ### HellingerDist,DiscreteDistribution,LatticeDistribution-method
+> ### HellingerDist,LatticeDistribution,LatticeDistribution-method
+> ### HellingerDist,numeric,DiscreteDistribution-method
+> ### HellingerDist,DiscreteDistribution,numeric-method
+> ### HellingerDist,numeric,AbscontDistribution-method
+> ### HellingerDist,AbscontDistribution,numeric-method
+> ### HellingerDist,AcDcLcDistribution,AcDcLcDistribution-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> HellingerDist(Norm(), Gumbel())
+Hellinger distance
+ 0.2204792
+> HellingerDist(Norm(), Td(10))
+Hellinger distance
+ 0.0598968
+> HellingerDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100)) # mutually singular
+Hellinger distance
+ 1
+> HellingerDist(Pois(10), Binom(size = 20))
+Hellinger distance
+ 0.1742254
+>
+> x <- rnorm(100)
+> HellingerDist(Norm(), x)
+Hellinger distance
+ 0.3287617
+> HellingerDist(x, Norm(), asis.smooth.discretize = "smooth")
+Hellinger distance
+ 0.1904838
+>
+> y <- (rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5)
+> HellingerDist(y, Norm())
+Hellinger distance
+ 0.7596996
+> HellingerDist(y, Norm(), asis.smooth.discretize = "smooth")
+Hellinger distance
+ 0.5283272
+>
+> HellingerDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5))
+Hellinger distance
+ 0.1945649
+>
+>
+>
+> cleanEx(); nameEx("KolmogorovDist")
+> ### * KolmogorovDist
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: KolmogorovDist
+> ### Title: Generic function for the computation of the Kolmogorov distance
+> ### of two distributions
+> ### Aliases: KolmogorovDist KolmogorovDist-methods
+> ### KolmogorovDist,AbscontDistribution,AbscontDistribution-method
+> ### KolmogorovDist,AbscontDistribution,DiscreteDistribution-method
+> ### KolmogorovDist,DiscreteDistribution,DiscreteDistribution-method
+> ### KolmogorovDist,DiscreteDistribution,AbscontDistribution-method
+> ### KolmogorovDist,LatticeDistribution,DiscreteDistribution-method
+> ### KolmogorovDist,DiscreteDistribution,LatticeDistribution-method
+> ### KolmogorovDist,LatticeDistribution,LatticeDistribution-method
+> ### KolmogorovDist,numeric,UnivariateDistribution-method
+> ### KolmogorovDist,UnivariateDistribution,numeric-method
+> ### KolmogorovDist,AcDcLcDistribution,AcDcLcDistribution-method
+> ### Keywords: distribution
+>
+> ### ** Examples
+>
+> KolmogorovDist(Norm(), Gumbel())
+Kolmogorov distance
+ 0.1501485
+> KolmogorovDist(Norm(), Td(10))
+Kolmogorov distance
+ 0.01554215
+> KolmogorovDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100))
+Kolmogorov distance
+ 0.03979462
+> KolmogorovDist(Pois(10), Binom(size = 20))
+Kolmogorov distance
+ 0.08863266
+> KolmogorovDist(Norm(), rnorm(100))
+Kolmogorov distance
+ 0.0659914
+> KolmogorovDist((rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5), Norm())
+Kolmogorov distance
+ 0.14
+> KolmogorovDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5))
+Kolmogorov distance
+ 0.1282777
+>
+>
+>
+> cleanEx(); nameEx("LMCondDistribution")
+> ### * LMCondDistribution
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: LMCondDistribution
+> ### Title: Generating function for the conditional distribution of a linear
+> ### regression model.
+> ### Aliases: LMCondDistribution
+> ### Keywords: distribution models
+>
+> ### ** Examples
+>
+> # normal error distribution
+> (D1 <- LMCondDistribution(theta = 1)) # corresponds to Norm(cond, 1)
+Distribution object of class: AbscontCondDistribution
+ theta: 1
+ intercept: 0
+ scale: 1
+## cond:
+name: conditioning by an Euclidean space
+Range: Euclidean Space with dimension 1
+> plot(D1)
+Warning in plot(D1) :
+ 'plot' not yet implemented for objects of class AbscontCondDistribution
+> r(D1)
+function (n, cond, ...)
+{
+ if (length(cond) != 1L)
+ stop("'cond' has wrong dimension")
+ r <- function (n)
+ {
+ rnorm(n, mean = 0, sd = 1)
+ }
+ 0 + cond %*% 1 + 1 * r(n, ...)
+}
+<environment: 0x5a6f620>
+> d(D1)
+function (x, cond, log = FALSE, ...)
+{
+ if (length(cond) != 1L)
+ stop("'cond' has wrong dimension")
+ d <- function (x, log = FALSE)
+ {
+ dnorm(x, mean = 0, sd = 1, log = log)
+ }
+ if ("log" %in% names(formals(d)))
+ d0 <- d((x - 0 - as.vector(cond %*% 1))/1, log = log)
+ else {
+ d0 <- d((x - 0 - as.vector(cond %*% 1))/1)
+ if (log)
+ d0 <- log(d0)
+ }
+ if (log)
+ d0 <- d0 - log(1)
+ else d0 <- d0/1
+ return(d0)
+}
+<environment: 0x5a6f620>
+> p(D1)
+function (q, cond, lower.tail = TRUE, log.p = FALSE, ...)
+{
+ if (length(cond) != 1L)
+ stop("'cond' has wrong dimension")
+ p <- function (q, lower.tail = TRUE, log.p = FALSE)
+ {
+ pnorm(q, mean = 0, sd = 1, lower.tail = lower.tail, log.p = log.p)
+ }
+ argList <- alist((q - 0 - as.vector(cond %*% 1))/1)
+ if ("lower.tail" %in% names(formals(p)))
+ argList <- c(argList, lower.tail = lower.tail)
+ if ("log.p" %in% names(formals(p)))
+ argList <- c(argList, log.p = log.p)
+ dots <- alist(...)
+ if (length(dots))
+ argList <- c(argList, dots)
+ p0 <- do.call(p, argList)
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/distr -r 607
More information about the Distr-commits
mailing list