[Distr-commits] r908 - branches branches/distr-2.5/pkg/distr branches/distr-2.5/pkg/distr/R branches/distr-2.5/pkg/distr/man branches/distr-2.5/pkg/distrMod branches/distr-2.5/pkg/distrSim branches/distr-2.5/pkg/utils pkg/distr pkg/distr/R pkg/distr/inst pkg/distr/man pkg/distr/src pkg/distrMod pkg/distrSim

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 12 10:04:46 CEST 2013


Author: ruckdeschel
Date: 2013-09-12 10:04:46 +0200 (Thu, 12 Sep 2013)
New Revision: 908

Added:
   branches/distr-2.6/
Modified:
   branches/distr-2.5/pkg/distr/DESCRIPTION
   branches/distr-2.5/pkg/distr/NAMESPACE
   branches/distr-2.5/pkg/distr/R/AllGenerics.R
   branches/distr-2.5/pkg/distr/man/internalGenerics.Rd
   branches/distr-2.5/pkg/distrMod/DESCRIPTION
   branches/distr-2.5/pkg/distrSim/DESCRIPTION
   branches/distr-2.5/pkg/utils/DESCRIPTIONutils.R
   pkg/distr/DESCRIPTION
   pkg/distr/R/AllGenerics.R
   pkg/distr/R/internals-qqplot.R
   pkg/distr/inst/NEWS
   pkg/distr/man/internalGenerics.Rd
   pkg/distr/src/ks.c
   pkg/distrMod/DESCRIPTION
   pkg/distrSim/DESCRIPTION
Log:
distr: reverted the changes in /src/library/stats/src/ks.c:
	including R.h etc is easier than thought...

Modified: branches/distr-2.5/pkg/distr/DESCRIPTION
===================================================================
--- branches/distr-2.5/pkg/distr/DESCRIPTION	2013-09-11 16:47:07 UTC (rev 907)
+++ branches/distr-2.5/pkg/distr/DESCRIPTION	2013-09-12 08:04:46 UTC (rev 908)
@@ -1,9 +1,13 @@
 Package: distr
-Version: 2.5.1
-Date: 2013-01-09
+Version: 2.5.2
+Date: 2013-09-12
 Title: Object oriented implementation of distributions
 Description: S4 Classes and Methods for distributions
-Author: Florian Camphausen, Matthias Kohl, Peter Ruckdeschel, Thomas Stabla
+Authors at R: c(person("Florian", "Camphausen", role=c("cre")),
+        person("Matthias", "Kohl", role=c("aut", "cph")), 
+		person("Peter", "Ruckdeschel", role=c("aut", "cph")), 
+		person("Thomas", "Stabla", role=c("aut", "cph")),
+        person("R Core Team", role = c("ctb", "cph")))
 Maintainer: Peter Ruckdeschel <Peter.Ruckdeschel at itwm.fraunhofer.de>
 Depends: R(>= 2.14.0), methods, graphics, startupmsg, sfsmisc, SweaveListingUtils
 Suggests: distrEx

Modified: branches/distr-2.5/pkg/distr/NAMESPACE
===================================================================
--- branches/distr-2.5/pkg/distr/NAMESPACE	2013-09-11 16:47:07 UTC (rev 907)
+++ branches/distr-2.5/pkg/distr/NAMESPACE	2013-09-12 08:04:46 UTC (rev 908)
@@ -97,4 +97,4 @@
 exportMethods("qqplot")
 export(".isEqual",".isEqual01", ".inArgs", ".fillList", 
        ".presubs", ".makeLenAndOrder", ".DistrCollapse")
-export("samplesize", "distribution")	   
\ No newline at end of file
+export("samplesize", "samplesize<-", "distribution")	   
\ No newline at end of file

Modified: branches/distr-2.5/pkg/distr/R/AllGenerics.R
===================================================================
--- branches/distr-2.5/pkg/distr/R/AllGenerics.R	2013-09-11 16:47:07 UTC (rev 907)
+++ branches/distr-2.5/pkg/distr/R/AllGenerics.R	2013-09-12 08:04:46 UTC (rev 908)
@@ -450,3 +450,7 @@
 if(!isGeneric("samplesize")){
     setGeneric("samplesize", function(object, ...) standardGeneric("samplesize"))
 }
+if(!isGeneric("samplesize<-")){
+    setGeneric("samplesize<-",
+        function(object, value) standardGeneric("samplesize<-"))
+}

Modified: branches/distr-2.5/pkg/distr/man/internalGenerics.Rd
===================================================================
--- branches/distr-2.5/pkg/distr/man/internalGenerics.Rd	2013-09-11 16:47:07 UTC (rev 907)
+++ branches/distr-2.5/pkg/distr/man/internalGenerics.Rd	2013-09-12 08:04:46 UTC (rev 908)
@@ -2,18 +2,22 @@
 \alias{internalGenerics}
 \alias{distribution}
 \alias{samplesize}
-\title{Internal: Common Generics 'distribution' and 'samplesize'}
+\alias{samplesize<-}
+\title{Internal: Common Generics 'distribution' and 'samplesize', 'samplesize<-'}
 \description{
-  In order to be able to use packages \pkg{distrSim} and \pkg{distrMod} independently,
+  In order to be able to use packages \pkg{distrSim} and \pkg{distrMod}
+  resp. \pkg{RobAStBase} independently,
   it is necessary to import the respective generic from a prior package, i.e.,
   \pkg{distr}.
   }
 \usage{
 distribution(object)
 samplesize(object, ...)
+x <- samplesize(object, value)
 }
 \arguments{
   \item{object}{ the first argument to dispatch on in the actual methods. }
+  \item{value}{ the value to be assigned. }
   \item{\dots}{ additional arguments for function \code{samplesize}. }
 }
 

Modified: branches/distr-2.5/pkg/distrMod/DESCRIPTION
===================================================================
--- branches/distr-2.5/pkg/distrMod/DESCRIPTION	2013-09-11 16:47:07 UTC (rev 907)
+++ branches/distr-2.5/pkg/distrMod/DESCRIPTION	2013-09-12 08:04:46 UTC (rev 908)
@@ -1,12 +1,12 @@
 Package: distrMod
-Version: 2.5.1
+Version: 2.5.2
 Date: 2013-01-09
 Title: Object oriented implementation of probability models
 Description: Object oriented implementation of probability models based on packages 'distr' and
         'distrEx'
 Author: Matthias Kohl, Peter Ruckdeschel
 Maintainer: Peter Ruckdeschel <Peter.Ruckdeschel at itwm.fraunhofer.de>
-Depends: R(>= 2.14.0), distr(>= 2.2), distrEx(>= 2.4), RandVar(>= 0.6.3),
+Depends: R(>= 2.14.0), distr(>= 2.5.2), distrEx(>= 2.4), RandVar(>= 0.6.3),
         MASS, stats4, methods
 ByteCompile: yes
 License: LGPL-3

Modified: branches/distr-2.5/pkg/distrSim/DESCRIPTION
===================================================================
--- branches/distr-2.5/pkg/distrSim/DESCRIPTION	2013-09-11 16:47:07 UTC (rev 907)
+++ branches/distr-2.5/pkg/distrSim/DESCRIPTION	2013-09-12 08:04:46 UTC (rev 908)
@@ -1,8 +1,8 @@
 Package: distrSim
-Version: 2.5.1
+Version: 2.5.2
 Date: 2013-11-09
 Title: Simulation classes based on package distr
-Depends: R(>= 2.6.0), methods, graphics, setRNG(>= 2006.2-1), distr(>= 2.2)
+Depends: R(>= 2.6.0), methods, graphics, setRNG(>= 2006.2-1), distr(>= 2.5.1)
 Suggests: distrEx(>= 2.2)
 Author: Florian Camphausen, Matthias Kohl, Peter Ruckdeschel, Thomas Stabla
 Description: Simulation (S4-)classes based on package distr

Modified: branches/distr-2.5/pkg/utils/DESCRIPTIONutils.R
===================================================================
--- branches/distr-2.5/pkg/utils/DESCRIPTIONutils.R	2013-09-11 16:47:07 UTC (rev 907)
+++ branches/distr-2.5/pkg/utils/DESCRIPTIONutils.R	2013-09-12 08:04:46 UTC (rev 908)
@@ -153,6 +153,18 @@
 changeDescription(startDir = "C:/rtest/robast",names=Names,
                   pkgs=Pkgs, values=Values)
 }
+
+if(FALSE){
+Pkgs <- c("RandVar", "RobAStBase", "RobAStRDA", "ROptEst", "RobExtremes")
+Names <- c("Version", "License")
+Values <- matrix(c(c("0.9.2","LGPL-3"),rep(c("0.9","LGPL-3"),4)),2,length(Pkgs))
+colnames(Values) <- Pkgs
+rownames(Values) <- Names
+changeDescription(startDir = "C:/rtest/robast/",names=Names,
+                  pkgs=Pkgs, values=Values)
+}
+
+}
 ##############################################################################
 
 

Modified: pkg/distr/DESCRIPTION
===================================================================
--- pkg/distr/DESCRIPTION	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distr/DESCRIPTION	2013-09-12 08:04:46 UTC (rev 908)
@@ -1,9 +1,13 @@
 Package: distr
-Version: 2.5
-Date: 2013-09-11
+Version: 2.5.1
+Date: 2013-01-09
 Title: Object oriented implementation of distributions
 Description: S4 Classes and Methods for distributions
-Author: Florian Camphausen, Matthias Kohl, Peter Ruckdeschel, Thomas Stabla
+Author: person("Florian", "Camphausen", role=c("cre")),
+        person("Matthias", "Kohl", role=c("aut", "cph")), 
+		person("Peter", "Ruckdeschel", role=c("aut", "cph"), 
+		person("Thomas", "Stabla", role=c("aut", "cph")),
+        person("R Core Team", role = c("ctb", "cph"))
 Maintainer: Peter Ruckdeschel <Peter.Ruckdeschel at itwm.fraunhofer.de>
 Depends: R(>= 2.14.0), methods, graphics, startupmsg, sfsmisc, SweaveListingUtils
 Suggests: distrEx

Modified: pkg/distr/R/AllGenerics.R
===================================================================
--- pkg/distr/R/AllGenerics.R	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distr/R/AllGenerics.R	2013-09-12 08:04:46 UTC (rev 908)
@@ -450,3 +450,7 @@
 if(!isGeneric("samplesize")){
     setGeneric("samplesize", function(object, ...) standardGeneric("samplesize"))
 }
+if(!isGeneric("samplesize<-")){
+    setGeneric("samplesize<-",
+        function(object, value) standardGeneric("samplesize<-"))
+}

Modified: pkg/distr/R/internals-qqplot.R
===================================================================
--- pkg/distr/R/internals-qqplot.R	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distr/R/internals-qqplot.R	2013-09-12 08:04:46 UTC (rev 908)
@@ -87,16 +87,18 @@
                      as.integer(n), PACKAGE = "stats")$p
         }else function(p0,n){
 #                 .Call(stats:::C_pKolmogorov2x, p0, n) #, PACKAGE = "stats")
-                 .C("pkolmogorov2x", p = as.double(p0),
-                     as.integer(n))$p
+#                 .C("pkolmogorov2x", p = as.double(p0),
+#                     as.integer(n))$p
+                 .Call("pKolmogorov2x", p0, n) #, PACKAGE = "stats")
         }
 .pks2 <- if(getRversion()<"2.16.0") function(x, tol){
                  .C("pkstwo", as.integer(1),
                     p = as.double(x), as.double(tol), PACKAGE = "stats")$p
         }else function(x, tol){
 #                 .Call(stats:::C_pKS2, p = x, tol) #, PACKAGE = "stats")
-                 .C("pkstwo", as.integer(1),
-                    p = as.double(x), as.double(tol))$p
+#                 .C("pkstwo", as.integer(1),
+#                    p = as.double(x), as.double(tol))$p
+                 .Call("pKS2", p = x, tol) #, PACKAGE = "stats")
         }
 
 

Modified: pkg/distr/inst/NEWS
===================================================================
--- pkg/distr/inst/NEWS	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distr/inst/NEWS	2013-09-12 08:04:46 UTC (rev 908)
@@ -25,12 +25,16 @@
             /src/library/stats/src/ks.c rev60573
    (with small changes to make it self-contained) to src folder of this pkg;
     in addition, we now use the shakier .C - interface again...
+	in v 2.5.1 reverted the changes in /src/library/stats/src/ks.c:
+	including R.h etc is easier than thought...
+	
 BUGFIXES:
 + fixed .makedotsPt -issue discovered by Gerald --> thx
 + moved generics to "distribution" and "samplesize" to pkg distr to avoid 
-   conflict with pkg distrMod
+   conflict between pkgs distrMod and distrSim
+   v 2.5.1: same with "samplesize<-"  to avoid conflict between pkgs 
+   distrSim and RobAStBase
 
-
 ##############
 v 2.4
 ##############

Modified: pkg/distr/man/internalGenerics.Rd
===================================================================
--- pkg/distr/man/internalGenerics.Rd	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distr/man/internalGenerics.Rd	2013-09-12 08:04:46 UTC (rev 908)
@@ -2,18 +2,22 @@
 \alias{internalGenerics}
 \alias{distribution}
 \alias{samplesize}
-\title{Internal: Common Generics 'distribution' and 'samplesize'}
+\alias{samplesize<-}
+\title{Internal: Common Generics 'distribution' and 'samplesize', 'samplesize<-'}
 \description{
-  In order to be able to use packages \pkg{distrSim} and \pkg{distrMod} independently,
+  In order to be able to use packages \pkg{distrSim} and \pkg{distrMod}
+  resp. \pkg{RobAStBase} independently,
   it is necessary to import the respective generic from a prior package, i.e.,
   \pkg{distr}.
   }
 \usage{
 distribution(object)
 samplesize(object, ...)
+x <- samplesize(object, value)
 }
 \arguments{
   \item{object}{ the first argument to dispatch on in the actual methods. }
+  \item{value}{ the value to be assigned. }
   \item{\dots}{ additional arguments for function \code{samplesize}. }
 }
 

Modified: pkg/distr/src/ks.c
===================================================================
--- pkg/distr/src/ks.c	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distr/src/ks.c	2013-09-12 08:04:46 UTC (rev 908)
@@ -26,67 +26,17 @@
    in the two-sided one-sample and two-sample cases.
 */
 
-#include <stdlib.h>
-#include <math.h>
-#define PI 3.141592653589793
-#ifndef M_1_SQRT_2PI
-#define M_1_SQRT_2PI	0.398942280401432677939946059934	/* 1/sqrt(2pi) */
-#endif
-#ifndef M_PI_2
-#define M_PI_2		1.570796326794896619231321691640	/* pi/2 */
-#endif
+#include <R.h>
+#include <Rinternals.h>
+#include <Rmath.h>		/* constants */
 
-#ifndef M_PI_4
-#define M_PI_4		0.785398163397448309615660845820	/* pi/4 */
-#endif
-
-/*
- * taken from R Core: /src/include/R_ext/RS.h rev60573
- */  
-extern void *R_chk_calloc(size_t, size_t);
-extern void *R_chk_realloc(void *, size_t);
-extern void R_chk_free(void *);
-
-/*
- * taken from R Core: /src/main/memory.c rev60573
- */  
-void *R_chk_calloc(size_t nelem, size_t elsize)
-{
-    void *p;
-    p = calloc(nelem, elsize);
-    return(p);
-}
-
-void *R_chk_realloc(void *ptr, size_t size)
-{
-    void *p;
-    /* Protect against broken realloc */
-    if(ptr) p = realloc(ptr, size); else p = malloc(size);
-    return(p);
-}
-
-void R_chk_free(void *ptr)
-{
-    /* S-PLUS warns here, but there seems no reason to do so */
-    /* if(!ptr) warning("attempt to free NULL pointer by Free"); */
-    if(ptr) free(ptr); /* ANSI C says free has no effect on NULL, but
-			  better to be safe here */
-}
-
-#define Calloc(n, t)   (t *) R_chk_calloc( (size_t) (n), sizeof(t) )
-#define Realloc(p,n,t) (t *) R_chk_realloc( (void *)(p), (size_t)((n) * sizeof(t)) )
-#define Free(p)        (R_chk_free( (void *)(p) ), (p) = NULL)
-
-/*static void pkolmogorov2x(double *x, int *n);
-static void pkstwo(int n, double *x, double tol);
-*/
 static double K(int n, double d);
 static void m_multiply(double *A, double *B, double *C, int m);
 static void m_power(double *A, int eA, double *V, int *eV, int m, int n);
 
 /* Two-sample two-sided asymptotic distribution */
-void
-pkstwo(int *n, double *x, double *tol)
+static void
+pkstwo(int n, double *x, double tol)
 {
 /* x[1:n] is input and output
  *
@@ -111,9 +61,9 @@
     double new, old, s, w, z;
     int i, k, k_max;
 
-    k_max = (int) sqrt(2 - log(*tol));
+    k_max = (int) sqrt(2 - log(tol));
 
-    for(i = 0; i < *n; i++) {
+    for(i = 0; i < n; i++) {
 	if(x[i] < 1) {
 	    z = - (M_PI_2 * M_PI_4) / (x[i] * x[i]);
 	    w = log(x[i]);
@@ -129,7 +79,7 @@
 	    k = 1;
 	    old = 0;
 	    new = 1;
-	    while(fabs(old - new) > *tol) {
+	    while(fabs(old - new) > tol) {
 		old = new;
 		new += 2 * s * exp(z * k * k);
 		s *= -1;
@@ -140,6 +90,44 @@
     }
 }
 
+/* Two-sided two-sample */
+static double psmirnov2x(double *x, int m, int n)
+{
+    double md, nd, q, *u, w;
+    int i, j;
+
+    if(m > n) {
+	i = n; n = m; m = i;
+    }
+    md = (double) m;
+    nd = (double) n;
+    /*
+       q has 0.5/mn added to ensure that rounding error doesn't
+       turn an equality into an inequality, eg abs(1/2-4/5)>3/10 
+
+    */
+    q = (0.5 + floor(*x * md * nd - 1e-7)) / (md * nd);
+    u = (double *) R_alloc(n + 1, sizeof(double));
+
+    for(j = 0; j <= n; j++) {
+	u[j] = ((j / nd) > q) ? 0 : 1;
+    }
+    for(i = 1; i <= m; i++) {
+	w = (double)(i) / ((double)(i + n));
+	if((i / md) > q)
+	    u[0] = 0;
+	else
+	    u[0] = w * u[0];
+	for(j = 1; j <= n; j++) {
+	    if(fabs(i / md - j / nd) > q) 
+		u[j] = 0;
+	    else
+		u[j] = w * u[j] + u[j - 1];
+	}
+    }
+    return u[n];
+}
+
 static double
 K(int n, double d)
 {
@@ -249,13 +237,31 @@
     }
     Free(B);
 }
-/*
- * taken from R Core: /src/library/stats/src/ks.c rev56090
-*/
-void pkolmogorov2x(double *x, int *n)
+
+/* Two-sided two-sample */
+SEXP pSmirnov2x(SEXP statistic, SEXP snx, SEXP sny)
 {
-    /* x is input and output. */
+    int nx = asInteger(snx), ny = asInteger(sny);
+    double st = asReal(statistic);
+    return ScalarReal(psmirnov2x(&st, nx, ny));
+}
 
-    *x = K(*n, *x);
+/* Two-sample two-sided asymptotic distribution */
+SEXP pKS2(SEXP statistic, SEXP stol)
+{
+    int n = LENGTH(statistic);
+    double tol = asReal(stol);
+    SEXP ans = duplicate(statistic);
+    pkstwo(n, REAL(ans), tol);
+    return ans;
 }
 
+
+/* The two-sided one-sample 'exact' distribution */
+SEXP pKolmogorov2x(SEXP statistic, SEXP sn)
+{
+    int n = asInteger(sn);
+    double st = asReal(statistic), p;
+    p = K(n, st);
+    return ScalarReal(p);
+}

Modified: pkg/distrMod/DESCRIPTION
===================================================================
--- pkg/distrMod/DESCRIPTION	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distrMod/DESCRIPTION	2013-09-12 08:04:46 UTC (rev 908)
@@ -1,16 +1,16 @@
 Package: distrMod
-Version: 2.5
-Date: 2013-09-11
+Version: 2.5.1
+Date: 2013-09-12
 Title: Object oriented implementation of probability models
 Description: Object oriented implementation of probability models based on packages 'distr' and
         'distrEx'
 Author: Matthias Kohl, Peter Ruckdeschel
 Maintainer: Peter Ruckdeschel <Peter.Ruckdeschel at itwm.fraunhofer.de>
-Depends: R(>= 2.14.0), distr(>= 2.2), distrEx(>= 2.4), RandVar(>= 0.6.3), MASS, stats4, methods
+Depends: R(>= 2.14.0), distr(>= 2.5.1), distrEx(>= 2.4), RandVar(>= 0.6.3), MASS, stats4, methods
 ByteCompile: yes
 License: LGPL-3
 Encoding: latin1
 URL: http://distr.r-forge.r-project.org/
 LastChangedDate: {$LastChangedDate$}
 LastChangedRevision: {$LastChangedRevision$}
-SVNRevision: 904
+SVNRevision: 905

Modified: pkg/distrSim/DESCRIPTION
===================================================================
--- pkg/distrSim/DESCRIPTION	2013-09-11 16:47:07 UTC (rev 907)
+++ pkg/distrSim/DESCRIPTION	2013-09-12 08:04:46 UTC (rev 908)
@@ -1,8 +1,8 @@
 Package: distrSim
-Version: 2.5
-Date: 2013-09-11
+Version: 2.5.1
+Date: 2013-09-12
 Title: Simulation classes based on package distr
-Depends: R(>= 2.6.0), methods, graphics, setRNG(>= 2006.2-1), distr(>= 2.2)
+Depends: R(>= 2.6.0), methods, graphics, setRNG(>= 2006.2-1), distr(>= 2.5.1)
 Suggests: distrEx(>= 2.2)
 Author: Florian Camphausen, Matthias Kohl, Peter Ruckdeschel, Thomas Stabla
 Description: Simulation (S4-)classes based on package distr
@@ -13,4 +13,4 @@
 URL: http://distr.r-forge.r-project.org/
 LastChangedDate: {$LastChangedDate$}
 LastChangedRevision: {$LastChangedRevision$}
-SVNRevision: 904
+SVNRevision: 905



More information about the Distr-commits mailing list