[Distr-commits] r1446 - in branches/distr-2.9/pkg: . distr distr/inst distr/src distr/tests/Examples distrEx distrEx/inst distrEx/src distrEx/tests/Examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 19 18:23:05 CEST 2024


Author: ruckdeschel
Date: 2024-08-19 18:23:04 +0200 (Mon, 19 Aug 2024)
New Revision: 1446

Added:
   branches/distr-2.9/pkg/20240819ChangesToDoForNewFeaturesIn_pkolmogororov+psmirnov_sinceRev60573.txt
   branches/distr-2.9/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save
Removed:
   branches/distr-2.9/pkg/distrEx/tests/Examples/distrEx-Ex_i386.Rout.save
   branches/distr-2.9/pkg/distrEx/tests/Examples/distrEx-Ex_x64.Rout.save
Modified:
   branches/distr-2.9/pkg/distr/DESCRIPTION
   branches/distr-2.9/pkg/distr/inst/NEWS
   branches/distr-2.9/pkg/distr/src/ks.c
   branches/distr-2.9/pkg/distr/tests/Examples/distr-Ex.Rout.save
   branches/distr-2.9/pkg/distrEx/DESCRIPTION
   branches/distr-2.9/pkg/distrEx/inst/NEWS
   branches/distr-2.9/pkg/distrEx/src/GLaw.c
Log:
[distr/distrEx] ported changes in trunk to devel versions and added a note what would need to be changed for exact code of pkolmogorov/psmirnov with ties

Added: branches/distr-2.9/pkg/20240819ChangesToDoForNewFeaturesIn_pkolmogororov+psmirnov_sinceRev60573.txt
===================================================================
--- branches/distr-2.9/pkg/20240819ChangesToDoForNewFeaturesIn_pkolmogororov+psmirnov_sinceRev60573.txt	                        (rev 0)
+++ branches/distr-2.9/pkg/20240819ChangesToDoForNewFeaturesIn_pkolmogororov+psmirnov_sinceRev60573.txt	2024-08-19 16:23:04 UTC (rev 1446)
@@ -0,0 +1,60 @@
+pkstwo wird ersetzt durch K2l
+
+    CALLDEF(pSmirnov2x, 3),
+    CALLDEF(pKolmogorov2x, 2),
+    CALLDEF(pKS2, 2),
+
+
+aus neu statsR.h
+SEXP psmirnov_exact(SEXP sq, SEXP sm, SEXP sn, SEXP sz, SEXP stwo, SEXP slower);
+SEXP pkolmogorov_two_exact(SEXP sq, SEXP sn);
+SEXP pkolmogorov_two_limit(SEXP sq, SEXP slower, SEXP stol);
+
+
+
+
+    CALLDEF(pkolmogorov_two_exact, 2),
+    CALLDEF(pkolmogorov_two_limit, 3),
+    CALLDEF(psmirnov_exact, 6),
+
+
+
+
+SEXP pkolmogorov_two_limit(SEXP sq, SEXP slower, SEXP stol)
+statt
+SEXP attribute_hidden pKS2(SEXP statistic, SEXP stol)
+
+
+
+SEXP psmirnov_exact(SEXP sq, SEXP sm, SEXP sn, SEXP sz,
+		    SEXP stwo, SEXP slower) {
+statt
+/* Two-sided two-sample */
+SEXP attribute_hidden pSmirnov2x(SEXP statistic, SEXP snx, SEXP sny)
+
+
+
+/* One-sample two-sided exact distribution */
+SEXP pkolmogorov_two_exact(SEXP sq, SEXP sn)
+{
+    int n = asInteger(sn), i;
+    SEXP ans;
+
+    PROTECT(ans = allocVector(REALSXP, LENGTH(sq)));
+    for(i = 0; i < LENGTH(sq); i++) {
+	REAL(ans)[i] = K2x(n, REAL(sq)[i]);
+    }
+    UNPROTECT(1);
+
+    return ans;
+}
+
+statt
+/* The two-sided one-sample 'exact' distribution */
+SEXP attribute_hidden pKolmogorov2x(SEXP statistic, SEXP sn)
+{
+    int n = asInteger(sn);
+    double st = asReal(statistic), p;
+    p = K(n, st);
+    return ScalarReal(p);
+}

Modified: branches/distr-2.9/pkg/distr/DESCRIPTION
===================================================================
--- branches/distr-2.9/pkg/distr/DESCRIPTION	2024-08-19 16:21:41 UTC (rev 1445)
+++ branches/distr-2.9/pkg/distr/DESCRIPTION	2024-08-19 16:23:04 UTC (rev 1446)
@@ -1,5 +1,5 @@
 Package: distr
-Version: 2.9.4
+Version: 2.9.5
 Date: 2024-01-28
 Title: Object Oriented Implementation of Distributions
 Description: S4-classes and methods for distributions as described in 

Modified: branches/distr-2.9/pkg/distr/inst/NEWS
===================================================================
--- branches/distr-2.9/pkg/distr/inst/NEWS	2024-08-19 16:21:41 UTC (rev 1445)
+++ branches/distr-2.9/pkg/distr/inst/NEWS	2024-08-19 16:23:04 UTC (rev 1446)
@@ -8,6 +8,14 @@
  information)
  
 ##############
+v 2.9.4
+##############
+
+under the hood:
++ to comply with _R_USE_STRICT_R_HEADERS_=true, we changed calls to Calloc and Free to
+  R_Calloc and R_Free in ks.c
+
+##############
 v 2.9.3
 ##############
 bug fixes

Modified: branches/distr-2.9/pkg/distr/src/ks.c
===================================================================
--- branches/distr-2.9/pkg/distr/src/ks.c	2024-08-19 16:21:41 UTC (rev 1445)
+++ branches/distr-2.9/pkg/distr/src/ks.c	2024-08-19 16:23:04 UTC (rev 1446)
@@ -158,8 +158,9 @@
    k = (int) (n * d) + 1;
    m = 2 * k - 1;
    h = k - n * d;
-   H = (double*) Calloc(m * m, double);
-   Q = (double*) Calloc(m * m, double);
+/* P.R. 20240819 changed Calloc to R_Calloc  */
+   H = (double*) R_Calloc(m * m, double);
+   Q = (double*) R_Calloc(m * m, double);
    for(i = 0; i < m; i++)
        for(j = 0; j < m; j++)
 	   if(i - j + 1 < 0)
@@ -187,8 +188,9 @@
        }
    }
    s *= pow(10., eQ);
-   Free(H);
-   Free(Q);
+/* P.R. 20240819 changed Free to R_Free  */
+   R_Free(H);
+   R_Free(Q);
    return(s);
 }
 
@@ -225,7 +227,8 @@
 	return;
     }
     m_power(A, eA, V, eV, m, n / 2);
-    B = (double*) Calloc(m * m, double);
+/* P.R. 20240819 changed Calloc to R_Calloc  */
+    B = (double*) R_Calloc(m * m, double);
     m_multiply(V, V, B, m);
     eB = 2 * (*eV);
     if((n % 2) == 0) {
@@ -242,7 +245,8 @@
 	    V[i] = V[i] * 1e-140;
 	*eV += 140;
     }
-    Free(B);
+/* P.R. 20240819 changed Free to R_Free  */
+    R_Free(B);
 }
 
 /* Two-sided two-sample */

Modified: branches/distr-2.9/pkg/distr/tests/Examples/distr-Ex.Rout.save
===================================================================
--- branches/distr-2.9/pkg/distr/tests/Examples/distr-Ex.Rout.save	2024-08-19 16:21:41 UTC (rev 1445)
+++ branches/distr-2.9/pkg/distr/tests/Examples/distr-Ex.Rout.save	2024-08-19 16:23:04 UTC (rev 1446)
@@ -1,7 +1,7 @@
 
-R version 4.1.2 Patched (2022-01-17 r81511) -- "Bird Hippie"
-Copyright (C) 2022 The R Foundation for Statistical Computing
-Platform: i386-w64-mingw32/i386 (32-bit)
+R Under development (unstable) (2024-08-17 r87027 ucrt) -- "Unsuffered Consequences"
+Copyright (C) 2024 The R Foundation for Statistical Computing
+Platform: x86_64-w64-mingw32/x64
 
 R is free software and comes with ABSOLUTELY NO WARRANTY.
 You are welcome to redistribute it under certain conditions.
@@ -23,7 +23,7 @@
 > options(pager = "console")
 > library('distr')
 Loading required package: startupmsg
-:startupmsg>  Utilities for Start-Up Messages (version 0.9.6)
+:startupmsg>  Utilities for Start-Up Messages (version 0.9.6.1)
 :startupmsg> 
 :startupmsg>  For more information see ?"startupmsg",
 :startupmsg>  NEWS("startupmsg")
@@ -30,7 +30,7 @@
 
 Loading required package: sfsmisc
 :distr>  Object Oriented Implementation of Distributions (version
-:distr>  2.9.2)
+:distr>  2.9.4)
 :distr> 
 :distr>  Attention: Arithmetics on distribution objects are
 :distr>  understood as operations on corresponding random variables
@@ -2006,8 +2006,10 @@
 > # squared standard normal distribution
 > ## IGNORE_RDIFF_BEGIN
 > x$dfun(4)
-[1] 0.0254851
+[1] 0.02548597
 > 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)
                     {if (log)
@@ -2014,8 +2016,8 @@
                           d0 <-    log(df1(x))-log(stand)
                      else d0 <- df1(x) / stand
                      return (d0)}
-<bytecode: 0x09c2ef58>
-<environment: 0x0f6c8ee0>
+<bytecode: 0x000001bdc208d238>
+<environment: 0x000001bdc7984f28>
 
 $pfun
 function (q, lower.tail = TRUE, log.p = FALSE) 
@@ -2030,7 +2032,7 @@
     else p0/nm
     return(p0)
 }
-<environment: 0x06fd13f0>
+<environment: 0x000001bdc2d8cbc8>
 
 $qfun
 function (p, lower.tail = TRUE, log.p = FALSE) 
@@ -2048,7 +2050,7 @@
     else q.l0(1 - p01)
     return(as.numeric(q0))
 }
-<environment: 0x0afadf58>
+<environment: 0x000001bdc2d3a7f0>
 
 > ## IGNORE_RDIFF_END
 > rp2 <- function(n){rpois(n, lambda = 1)^2}
@@ -2079,8 +2081,10 @@
 > # squared standard  normal distribution
 > ## IGNORE_RDIFF_BEGIN
 > x$dfun(4)
-[1] 0.0254851
+[1] 0.02548597
 > 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)
                     {if (log)
@@ -2087,8 +2091,8 @@
                           d0 <-    log(df1(x))-log(stand)
                      else d0 <- df1(x) / stand
                      return (d0)}
-<bytecode: 0x09c2ef58>
-<environment: 0x0a602690>
+<bytecode: 0x000001bdc208d238>
+<environment: 0x000001bdc2b5ea18>
 
 $pfun
 function (q, lower.tail = TRUE, log.p = FALSE) 
@@ -2103,7 +2107,7 @@
     else p0/nm
     return(p0)
 }
-<environment: 0x0a49bf18>
+<environment: 0x000001bdc283b2a8>
 
 $qfun
 function (p, lower.tail = TRUE, log.p = FALSE) 
@@ -2121,7 +2125,7 @@
     else q.l0(1 - p01)
     return(as.numeric(q0))
 }
-<environment: 0x0a483368>
+<environment: 0x000001bdc5d04b20>
 
 > ## IGNORE_RDIFF_END
 > rp2 <- function(n){rpois(n, lambda = 1)^2}
@@ -3625,11 +3629,11 @@
         sim.left sim.right   pw.left pw.right
  [1,] 0.00282976   1.90952 0.0323441  1.04733
  [2,] 0.00282976   1.94981 0.0323440  1.04733
- [3,] 0.00282976   2.03254 0.0323440  1.04733
+ [3,] 0.00282976   2.03254 0.0323441  1.04733
  [4,] 0.00282976   2.22519 0.2156880  1.41067
  [5,] 0.00282976   2.70502 0.7135654  2.16947
  [6,] 0.00282976   2.71956 0.7135654  2.16947
- [7,] 0.00282976   3.02067 1.0115330  2.60787
+ [7,] 0.00282976   3.02067 1.0115331  2.60787
  [8,] 0.00282976   3.15281 1.0115330  2.60787
  [9,] 0.20789178   3.28363 1.1570344  2.82255
 [10,] 0.78261897   3.63713 1.4471670  3.25405
@@ -3648,11 +3652,11 @@
 [23,] 3.22446707  10.17629 3.5391176  6.67894
 [24,] 3.43239404  14.95072 3.7815571  7.13538
 [25,] 3.75255614  33.37684 4.3395390  8.26585
-[26,] 3.76891063  33.37684 4.3395390  8.26585
+[26,] 3.76891063  33.37684 4.3395389  8.26585
 [27,] 4.23622865  33.37684 5.0503475  9.93760
 [28,] 4.29137291  33.37684 5.0503475  9.93760
 [29,] 4.30493804  33.37684 5.0503475  9.93760
-[30,] 4.68094638  33.37684 5.5034154 11.21826
+[30,] 4.68094638  33.37684 5.5034155 11.21826
 
 $err
  sim   pw 
@@ -3806,13 +3810,13 @@
 > ## IGNORE_RDIFF_BEGIN
 > system.time(r(F)(10^6))
    user  system elapsed 
-   0.38    0.00    0.37 
+   0.30    0.01    0.31 
 > ## IGNORE_RDIFF_END
 > simplifyr(F, size = 10^6)
 > ## IGNORE_RDIFF_BEGIN
 > system.time(r(F)(10^6))
    user  system elapsed 
-   0.13    0.00    0.13 
+   0.10    0.02    0.10 
 > ## IGNORE_RDIFF_END
 > 
 > 
@@ -3849,7 +3853,7 @@
 > cleanEx()
 > options(digits = 7L)
 > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed:  25.75 2.3 29.29 NA NA 
+Time elapsed:  23.82 1.72 26 NA NA 
 > grDevices::dev.off()
 pdf 
  19 

Modified: branches/distr-2.9/pkg/distrEx/DESCRIPTION
===================================================================
--- branches/distr-2.9/pkg/distrEx/DESCRIPTION	2024-08-19 16:21:41 UTC (rev 1445)
+++ branches/distr-2.9/pkg/distrEx/DESCRIPTION	2024-08-19 16:23:04 UTC (rev 1446)
@@ -1,5 +1,5 @@
 Package: distrEx
-Version: 2.9.3
+Version: 2.9.4
 Date: 2023-11-27
 Title: Extensions of Package 'distr'
 Description: Extends package 'distr' by functionals, distances, and conditional distributions.

Modified: branches/distr-2.9/pkg/distrEx/inst/NEWS
===================================================================
--- branches/distr-2.9/pkg/distrEx/inst/NEWS	2024-08-19 16:21:41 UTC (rev 1445)
+++ branches/distr-2.9/pkg/distrEx/inst/NEWS	2024-08-19 16:23:04 UTC (rev 1446)
@@ -8,6 +8,13 @@
  information)
 
 ##############
+v 2.9.3
+##############
+
+under the hood:
++ to comply with _R_USE_STRICT_R_HEADERS_=true, we changed calls to PI to M_PI in GLaw.c
+
+##############
 v 2.9
 ##############
 

Modified: branches/distr-2.9/pkg/distrEx/src/GLaw.c
===================================================================
--- branches/distr-2.9/pkg/distrEx/src/GLaw.c	2024-08-19 16:21:41 UTC (rev 1445)
+++ branches/distr-2.9/pkg/distrEx/src/GLaw.c	2024-08-19 16:23:04 UTC (rev 1446)
@@ -9,7 +9,8 @@
 void attribute_hidden gauleg(int *n, double *eps, double *A, double *W)
 { int i,j, m=((*n)+1)/2; double z1,z,pp,p1,p2,p3;
       for(i=1;i<=m;i++){
-        z=cos(PI*(i-0.25)/((*n)+0.5));
+/* P.R. 20240819 changed PI to M_PI  */
+        z=cos(M_PI*(i-0.25)/((*n)+0.5));
         do{ p1=1.0;
             p2=0.0;
             for(j=1;j<=(*n);j++){

Added: branches/distr-2.9/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save
===================================================================
--- branches/distr-2.9/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save	                        (rev 0)
+++ branches/distr-2.9/pkg/distrEx/tests/Examples/distrEx-Ex.Rout.save	2024-08-19 16:23:04 UTC (rev 1446)
@@ -0,0 +1,1647 @@
+
+R Under development (unstable) (2024-08-17 r87027 ucrt) -- "Unsuffered Consequences"
+Copyright (C) 2024 The R Foundation for Statistical Computing
+Platform: x86_64-w64-mingw32/x64
+
+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.
+
+> pkgname <- "distrEx"
+> source(file.path(R.home("share"), "R", "examples-header.R"))
+> options(warn = 1)
+> options(pager = "console")
+> library('distrEx')
+Loading required package: distr
+Loading required package: startupmsg
+:startupmsg>  Utilities for Start-Up Messages (version 0.9.6.1)
+:startupmsg> 
+:startupmsg>  For more information see ?"startupmsg",
+:startupmsg>  NEWS("startupmsg")
+
+Loading required package: sfsmisc
+:distr>  Object Oriented Implementation of Distributions (version
+:distr>  2.9.4)
+: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 objects are masked from 'package:stats':
+
+    df, qqplot, sd
+
+:distrEx>  Extensions of Package 'distr' (version 2.9.3)
+:distrEx> 
+:distrEx>  Note: Packages "e1071", "moments", "fBasics" should be
+:distrEx>  attached /before/ package "distrEx". See
+:distrEx>  distrExMASK().Note: Extreme value distribution
+:distrEx>  functionality has been moved to
+:distrEx> 
+:distrEx>        package "RobExtremes". See distrExMOVED().
+: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 objects are masked from 'package:stats':
+
+    IQR, mad, median, var
+
+> 
+> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
+> base::assign(".old_wd", base::getwd(), 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(), UnivarMixingDistribution(Norm(1,2),Norm(0.5,3),
++                  mixCoeff=c(0.2,0.8)), rho=0.3)
+asym. total variation distance 
+                     0.5311789 
+> 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.2663399 
+> 
+> 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.6324715 
+> 
+> AsymTotalVarDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5), rho=0.3)
+asym. total variation distance 
+                      0.292515 
+> 
+> 
+> 
+> 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(), UnivarMixingDistribution(Norm(1,2),Norm(0.5,3),
++                  mixCoeff=c(0.2,0.8)))
+CvM distance 
+   0.1812994 
+> CvMDist(Norm(), UnivarMixingDistribution(Norm(1,2),Norm(0.5,3),
++                  mixCoeff=c(0.2,0.8)),mu=Norm())
+CvM distance 
+   0.1812994 
+> CvMDist(Norm(), Td(10))
+CvM distance 
+ 0.009330691 
+> CvMDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100))
+CvM distance 
+  0.01746156 
+> CvMDist(Pois(10), Binom(size = 20)) 
+CvM distance 
+  0.06107322 
+> CvMDist(rnorm(100),Norm())
+CvM distance 
+  0.04308361 
+> CvMDist((rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5), Norm())
+CvM distance 
+    0.123967 
+> CvMDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5))
+CvM distance 
+   0.1307281 
+> 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
+> ## in RStudio or Jupyter IRKernel, use q.l(.)(.) instead of q(.)(.)
+> 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 multivariate discrete distribution
+> ### 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,Geom,missing,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,Pois,missing,missing-method E,Td,missing,missing-method
+> ###   E,Unif,missing,missing-method E,Weibull,missing,missing-method
+> ###   E,Gammad,function,missing-method E,Weibull,function,missing-method
+> ###   E,Cauchy,function,missing-method .qtlIntegrate
+> ### 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.999918
+> 
+> # 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.75
+> # some Lebesgue decomposed distribution 
+> mymix <- UnivarLebDecDistribution(acPart = Norm(), discretePart = Binom(4,.4),
++          acWeight = 0.4)
+> E(mymix)
+[1] 0.96
+> 
+> 
+> 
+> cleanEx()
+> nameEx("EmpiricalMVDistribution")
+> ### * EmpiricalMVDistribution
+> 
+> flush(stderr()); flush(stdout())
+> 
+> ### Name: EmpiricalMVDistribution
+> ### Title: Generating function for mulitvariate discrete distribution
+> ### Aliases: EmpiricalMVDistribution
+> ### Keywords: distribution
+> 
+> ### ** Examples
+> 
+> ## generate some data
+> X <- matrix(rnorm(50), ncol = 5)
+> 
+> ## empirical distribution of X
+> D1 <- EmpiricalMVDistribution(data = X)
+> support(D1)
+            [,1]        [,2]        [,3]        [,4]       [,5]
+ [1,] -0.6264538  1.51178117  0.91897737  1.35867955 -0.1645236
+ [2,]  0.1836433  0.38984324  0.78213630 -0.10278773 -0.2533617
+ [3,] -0.8356286 -0.62124058  0.07456498  0.38767161  0.6969634
+ [4,]  1.5952808 -2.21469989 -1.98935170 -0.05380504  0.5566632
+ [5,]  0.3295078  1.12493092  0.61982575 -1.37705956 -0.6887557
+ [6,] -0.8204684 -0.04493361 -0.05612874 -0.41499456 -0.7074952
+ [7,]  0.4874291 -0.01619026 -0.15579551 -0.39428995  0.3645820
+ [8,]  0.7383247  0.94383621 -1.47075238 -0.05931340  0.7685329
+ [9,]  0.5757814  0.82122120 -0.47815006  1.10002537 -0.1123462
+[10,] -0.3053884  0.59390132  0.41794156  0.76317575  0.8811077
+> r(D1)(10)
+            [,1]        [,2]        [,3]        [,4]       [,5]
+ [1,]  0.7383247  0.94383621 -1.47075238 -0.05931340  0.7685329
+ [2,]  0.3295078  1.12493092  0.61982575 -1.37705956 -0.6887557
+ [3,]  1.5952808 -2.21469989 -1.98935170 -0.05380504  0.5566632
+ [4,] -0.6264538  1.51178117  0.91897737  1.35867955 -0.1645236
+ [5,]  0.7383247  0.94383621 -1.47075238 -0.05931340  0.7685329
+ [6,]  1.5952808 -2.21469989 -1.98935170 -0.05380504  0.5566632
+ [7,] -0.8356286 -0.62124058  0.07456498  0.38767161  0.6969634
+ [8,] -0.8204684 -0.04493361 -0.05612874 -0.41499456 -0.7074952
+ [9,] -0.6264538  1.51178117  0.91897737  1.35867955 -0.1645236
+[10,]  0.4874291 -0.01619026 -0.15579551 -0.39428995  0.3645820
+> 
+> 
+> 
+> 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 < 1e-11
+> GLIntegrate(dnorm, -1.96, 1.96)
+[1] 0.9500042
+> 
+> 
+> 
+> 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
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/distr -r 1446


More information about the Distr-commits mailing list