[Distr-commits] r237 - branches/distr-2.0/pkg/distrEx/src pkg/distr pkg/distr/R pkg/distr/man pkg/distrDoc/inst pkg/distrDoc/inst/doc pkg/distrEx/R pkg/distrEx/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 5 14:40:48 CEST 2008
Author: ruckdeschel
Date: 2008-08-05 14:40:48 +0200 (Tue, 05 Aug 2008)
New Revision: 237
Removed:
pkg/distrDoc/inst/distr.tex
Modified:
branches/distr-2.0/pkg/distrEx/src/distrEx.dll
pkg/distr/NAMESPACE
pkg/distr/R/AllClasses.R
pkg/distr/R/AllInitialize.R
pkg/distr/man/0distr-package.Rd
pkg/distrDoc/inst/doc/distr.Rnw
pkg/distrEx/R/Expectation.R
pkg/distrEx/R/Functionals.R
pkg/distrEx/R/Kurtosis.R
pkg/distrEx/R/Skewness.R
pkg/distrEx/man/E.Rd
pkg/distrEx/man/Var.Rd
Log:
new Arcsine Distribution
Modified: branches/distr-2.0/pkg/distrEx/src/distrEx.dll
===================================================================
(Binary files differ)
Modified: pkg/distr/NAMESPACE
===================================================================
--- pkg/distr/NAMESPACE 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distr/NAMESPACE 2008-08-05 12:40:48 UTC (rev 237)
@@ -8,7 +8,7 @@
"Dirac","Exp", "DExp", "Fd", "Gammad",
"Geom", "Hyper", "Lnorm", "Logis",
"Nbinom", "Norm", "Pois", "RtoDPQ",
- "RtoDPQ.d", "Td", "Unif", "Weibull",
+ "RtoDPQ.d", "Td", "Unif", "Weibull", "Arcsine",
"distroptions", "getdistrOption", "simplifyr",
"Lattice", "DiscreteDistribution",
"LatticeDistribution", "EuclideanSpace", "Reals",
@@ -38,7 +38,7 @@
"Beta", "Binom", "Cauchy", "Chisq", "Dirac",
"DExp", "Exp", "Fd", "Gammad", "Geom",
"Hyper", "Logis", "Lnorm", "Nbinom", "Norm",
- "Pois", "Td", "Unif", "Weibull",
+ "Pois", "Td", "Unif", "Weibull", "Arcsine",
"ExpOrGammaOrChisq")
exportClasses("DistrList",
"UnivarDistrList")
Modified: pkg/distr/R/AllClasses.R
===================================================================
--- pkg/distr/R/AllClasses.R 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distr/R/AllClasses.R 2008-08-05 12:40:48 UTC (rev 237)
@@ -598,6 +598,38 @@
contains = "AbscontDistribution"
)
+## Class: Arcsine distribution
+setClass("Arcsine",
+ prototype = prototype(
+ r = function(n){ sin((runif(n)-.5)*pi) },
+ d = function(x, log = FALSE){
+ x0 <- (abs(x)<1-.Machine$double.eps)
+ x1 <- x^2*x0
+ d <- x0/sqrt(1-x1)/pi
+ d[.isEqual(abs(x),1)] <- Inf
+ if(log) d<- log(d)
+ return(d)},
+ p = function(q, lower.tail = TRUE, log.p = FALSE ){
+ if(!lower.tail) q<- -q
+ q <- pmin(pmax(q,-1),1)
+ p <- asin(q)/pi+1/2
+ if(log.p) p <- log(p)
+ return(p)},
+ q = function(p, lower.tail = TRUE, log.p = FALSE ){
+ if(log.p) p <- exp(p)
+ p1 <- p
+ p1[p<0|p>1] <- 0.5
+ if(!lower.tail) p1 <- 1-p1
+ q <- sin( (p1-1/2)*pi)
+ q[p<0|p>1] <- NA
+ q[.isEqual(p,0)] <- -1
+ q[.isEqual(p,1)] <- 1
+ return(q)}
+ ),
+ contains = "AbscontDistribution"
+ )
+
+
## inbetween-Class: AffLinAbscontDistribution
setClass("AffLinAbscontDistribution",
Modified: pkg/distr/R/AllInitialize.R
===================================================================
--- pkg/distr/R/AllInitialize.R 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distr/R/AllInitialize.R 2008-08-05 12:40:48 UTC (rev 237)
@@ -1021,3 +1021,35 @@
.Object
})
+## Class: Arcsine distribution
+setMethod("initialize", "Arcsine",
+ function(.Object, .withArith = FALSE) {
+ .Object at img <- new("Reals")
+ .Object at r <- function(n){sin((runif(n)-.5)*pi)}
+ .Object at d <- function(x, log = FALSE){
+ x0 <- (abs(x)<1-.Machine$double.eps)
+ x1 <- x^2*x0
+ d <- x0/sqrt(1-x1)/pi
+ d[.isEqual(abs(x),1)] <- Inf
+ if(log) d<- log(d)
+ return(d)}
+ .Object at p <- function(q, lower.tail = TRUE, log.p = FALSE){
+ if(!lower.tail) q<- -q
+ q <- pmin(pmax(q,-1),1)
+ p <- asin(q)/pi+1/2
+ if(log.p) p <- log(p)
+ return(p)}
+ .Object at q <- function(p, lower.tail = TRUE, log.p = FALSE){
+ if(log.p) p <- exp(p)
+ p1 <- p
+ p1[p<0|p>1] <- 0.5
+ if(!lower.tail) p1 <- 1-p1
+ q <- sin( (p1-1/2)*pi)
+ q[p<0|p>1] <- NA
+ q[.isEqual(p,0)] <- -1
+ q[.isEqual(p,1)] <- 1
+ return(q)}
+ .Object at .withSim <- FALSE
+ .Object at .withArith <- .withArith
+ .Object
+ })
Modified: pkg/distr/man/0distr-package.Rd
===================================================================
--- pkg/distr/man/0distr-package.Rd 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distr/man/0distr-package.Rd 2008-08-05 12:40:48 UTC (rev 237)
@@ -120,6 +120,7 @@
|>|>|>|>"AffLinUnivarLebDecDistribution"
|>|>"AbscontDistribution"
|>|>|>"AffLinAbscontDistribution"
+|>|>|>"Arcsine"
|>|>|>"Beta"
|>|>|>"Cauchy"
|>|>|>"ExpOrGammaOrChisq" (VIRTUAL)
Deleted: pkg/distrDoc/inst/distr.tex
===================================================================
Modified: pkg/distrDoc/inst/doc/distr.Rnw
===================================================================
--- pkg/distrDoc/inst/doc/distr.Rnw 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distrDoc/inst/doc/distr.Rnw 2008-08-05 12:40:48 UTC (rev 237)
@@ -1347,7 +1347,7 @@
corresponding \code{d} respective \code{r} slots with the additional
argument \code{cond}.
\paragraph{exact evaluation}
-is available for \code{X} of class \code{Beta} (for noncentrality $0$),
+is available for \code{X} of class \code{Arcsine}, \code{Beta} (for noncentrality $0$),
\code{Binom}, \code{Cauchy}, \code{Chisq}, \code{Dirac}, \code{Exp}, \code{Fd},
\code{Gammad}, \code{Geom}, \code{Hyper}, \code{Logis}, \code{Lnorm},
\code{Nbinom}, \code{Norm}, \code{Pois}, \code{Td}, \code{Unif}, \code{Weibull}.
@@ -1422,7 +1422,7 @@
available.
\paragraph{exact evaluation} is provided for specific distributions if no
function and no condition argument is given:
-this is available for \code{X} of class \code{Beta} (for noncentrality $0$),
+this is available for \code{X} of class \code{Arcsine}, \code{Beta} (for noncentrality $0$),
\code{Binom}, \code{Cauchy}, \code{Chisq},\code{Dirac}, \code{Exp}, \code{Fd},
\code{Gammad}, \code{Geom}, \code{Hyper}, \code{Logis}, \code{Lnorm},
\code{Nbinom}, \code{Norm}, \code{Pois}, \code{Unif}, \code{Td}, \code{Weibull}.
Modified: pkg/distrEx/R/Expectation.R
===================================================================
--- pkg/distrEx/R/Expectation.R 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distrEx/R/Expectation.R 2008-08-05 12:40:48 UTC (rev 237)
@@ -417,3 +417,9 @@
function(object, fun, cond){
return(scale(object)*gamma(1+1/shape(object)))
})
+setMethod("E", signature(object = "Arcsine",
+ fun = "missing",
+ cond = "missing"),
+ function(object, fun, cond){
+ return(0)
+ })
Modified: pkg/distrEx/R/Functionals.R
===================================================================
--- pkg/distrEx/R/Functionals.R 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distrEx/R/Functionals.R 2008-08-05 12:40:48 UTC (rev 237)
@@ -308,6 +308,14 @@
return(a*b/(a+b)^2/(a+b+1))}
})
+setMethod("var", signature(x = "Arcsine"),
+ function(x, ...){
+ if((hasArg(fun))||(hasArg(cond))||(!isTRUE(all.equal(ncp(x),0))))
+ return(var(as(x,"AbscontDistribution"),...))
+ else
+ {return(1/2)}
+ })
+
#################################################################
# some exact medians
#################################################################
@@ -339,6 +347,9 @@
setMethod("median", signature(x = "Unif"),
function(x) (Min(x)+Max(x))/2)
+setMethod("median", signature(x = "Arcsine"),
+ function(x) 0)
+
#################################################################
# some exact IQRs
#################################################################
@@ -368,6 +379,9 @@
setMethod("IQR", signature(x = "Unif"),
function(x) (Max(x)-Min(x))/2)
+setMethod("IQR", signature(x = "Arcsine"),
+ function(x) sqrt(2))
+
#################################################################
# some exact mads
#################################################################
@@ -399,3 +413,5 @@
setMethod("mad", signature(x = "Unif"),
function(x) (Max(x)-Min(x))/4)
+setMethod("mad", signature(x = "Arcsine"),
+ function(x) sqrt(1/2))
Modified: pkg/distrEx/R/Kurtosis.R
===================================================================
--- pkg/distrEx/R/Kurtosis.R 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distrEx/R/Kurtosis.R 2008-08-05 12:40:48 UTC (rev 237)
@@ -252,6 +252,17 @@
return(6*(a^3-a^2*(2*b-1)+b^2*(b+1)-2*a*b*(b+2))/(a*b*(a+b+2)*(a+b+3)) )}
})
+###################################################################################
+#kurtosis --- code P.R.:
+###################################################################################
+setMethod("kurtosis", signature(x = "Arcsine"),
+ function(x, ...){
+ if((hasArg(fun))||(hasArg(cond))||(!isTRUE(all.equal(ncp(x),0))))
+ return(kurtosis(as(x,"AbscontDistribution"),...))
+ else
+ {return(-3/2)}
+ })
+
Modified: pkg/distrEx/R/Skewness.R
===================================================================
--- pkg/distrEx/R/Skewness.R 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distrEx/R/Skewness.R 2008-08-05 12:40:48 UTC (rev 237)
@@ -232,7 +232,18 @@
return( 2*(b-a)*sqrt(a+b+1)/(a+b+2)/sqrt(a*b) ) }
})
+###################################################################################
+#skewness --- code P.R.:
+###################################################################################
+setMethod("skewness", signature(x = "Arcsine"),
+ function(x, ...){
+ if((hasArg(fun))||(hasArg(cond))||(!isTRUE(all.equal(ncp(x),0))))
+ return(skewness(as(x,"AbscontDistribution"),...))
+ else
+ {return( 0 ) }
+ })
+
Modified: pkg/distrEx/man/E.Rd
===================================================================
--- pkg/distrEx/man/E.Rd 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distrEx/man/E.Rd 2008-08-05 12:40:48 UTC (rev 237)
@@ -45,6 +45,7 @@
\alias{E,Td,missing,missing-method}
\alias{E,Unif,missing,missing-method}
\alias{E,Weibull,missing,missing-method}
+\alias{E,Arcsine,missing,missing-method}
\title{Generic Function for the Computation of (Conditional) Expectations}
\description{
@@ -98,6 +99,7 @@
\S4method{E}{Unif,missing,missing}(object, fun, cond)
\S4method{E}{Td,missing,missing}(object, fun, cond)
\S4method{E}{Weibull,missing,missing}(object, fun, cond)
+\S4method{E}{Arcsine,missing,missing}(object, fun, cond)
}
\arguments{
@@ -239,6 +241,8 @@
exact evaluation using explicit expressions.}
\item{object = "Weibull", fun = "missing", cond = "missing":}{
exact evaluation using explicit expressions.}
+ \item{object = "Arcsine", fun = "missing", cond = "missing":}{
+ exact evaluation using explicit expressions.}
}}
%\references{ ~put references to the literature/web site here ~ }
\author{Matthias Kohl \email{Matthias.Kohl at stamats.de} and Peter Ruckdeschel \email{peter.ruckdeschel at uni-bayreuth.de}}
Modified: pkg/distrEx/man/Var.Rd
===================================================================
--- pkg/distrEx/man/Var.Rd 2008-08-05 12:09:25 UTC (rev 236)
+++ pkg/distrEx/man/Var.Rd 2008-08-05 12:40:48 UTC (rev 237)
@@ -26,6 +26,7 @@
\alias{var,Unif-method}
\alias{var,Weibull-method}
\alias{var,Td-method}
+\alias{var,Arcsine-method}
\alias{sd}
\alias{sd-methods}
\alias{sd,UnivariateDistribution-method}
@@ -46,6 +47,7 @@
\alias{median,Lnorm-method}
\alias{median,Norm-method}
\alias{median,Unif-method}
+\alias{median,Arcsine-method}
\alias{IQR}
\alias{IQR-methods}
\alias{IQR,ANY-method}
@@ -63,6 +65,7 @@
\alias{IQR,Logis-method}
\alias{IQR,Norm-method}
\alias{IQR,Unif-method}
+\alias{IQR,Arcsine-method}
\alias{mad}
\alias{mad,ANY-method}
\alias{mad-methods}
@@ -79,6 +82,7 @@
\alias{mad,Logis-method}
\alias{mad,Norm-method}
\alias{mad,Unif-method}
+\alias{mad,Arcsine-method}
\alias{skewness}
\alias{skewness-methods}
\alias{skewness,ANY-method}
@@ -106,6 +110,7 @@
\alias{skewness,Unif-method}
\alias{skewness,Weibull-method}
\alias{skewness,Td-method}
+\alias{skewness,Arcsine-method}
\alias{kurtosis}
\alias{kurtosis-methods}
\alias{kurtosis,ANY-method}
@@ -133,6 +138,7 @@
\alias{kurtosis,Unif-method}
\alias{kurtosis,Weibull-method}
\alias{kurtosis,Td-method}
+\alias{kurtosis,Arcsine-method}
\title{Generic Functions for the Computation of Functionals}
\description{
@@ -152,6 +158,7 @@
\S4method{IQR}{Logis}(x)
\S4method{IQR}{Norm}(x)
\S4method{IQR}{Unif}(x)
+\S4method{IQR}{Arcsine}(x)
median(x, ...)
@@ -166,6 +173,7 @@
\S4method{median}{Lnorm}(x)
\S4method{median}{Norm}(x)
\S4method{median}{Unif}(x)
+\S4method{median}{Arcsine}(x)
mad(x, ...)
@@ -179,6 +187,7 @@
\S4method{mad}{Logis}(x)
\S4method{mad}{Norm}(x)
\S4method{mad}{Unif}(x)
+\S4method{mad}{Arcsine}(x)
sd(x, ...)
@@ -207,6 +216,7 @@
\S4method{var}{Td}(x, ...)
\S4method{var}{Unif}(x, ...)
\S4method{var}{Weibull}(x, ...)
+\S4method{var}{Arcsine}(x, ...)
skewness(x, ...)
\S4method{skewness}{UnivariateDistribution}(x, fun, cond, withCond, useApply, ...)
@@ -230,6 +240,7 @@
\S4method{skewness}{Td}(x, ...)
\S4method{skewness}{Unif}(x, ...)
\S4method{skewness}{Weibull}(x, ...)
+\S4method{skewness}{Arcsine}(x, ...)
kurtosis(x, ...)
\S4method{kurtosis}{UnivariateDistribution}(x, fun, cond, withCond, useApply, ...)
@@ -253,6 +264,7 @@
\S4method{kurtosis}{Td}(x, ...)
\S4method{kurtosis}{Unif}(x, ...)
\S4method{kurtosis}{Weibull}(x, ...)
+\S4method{kurtosis}{Arcsine}(x, ...)
}
\arguments{
\item{x}{ object of class \code{"UnivariateDistribution"}}
@@ -369,6 +381,8 @@
exact evaluation using explicit expressions.}
\item{\code{var}, \code{signature(x = "Weibull")}:}{
exact evaluation using explicit expressions.}
+ \item{\code{var}, \code{signature(x = "Arcsine")}:}{
+ exact evaluation using explicit expressions.}
\item{\code{IQR}, \code{signature(x = "Cauchy")}:}{
exact evaluation using explicit expressions.}
\item{\code{IQR}, \code{signature(x = "Dirac")}:}{
@@ -385,6 +399,8 @@
exact evaluation using explicit expressions.}
\item{\code{IQR}, \code{signature(x = "Unif")}:}{
exact evaluation using explicit expressions.}
+ \item{\code{IQR}, \code{signature(x = "Arcsine")}:}{
+ exact evaluation using explicit expressions.}
\item{\code{median}, \code{signature(x = "Cauchy")}:}{
exact evaluation using explicit expressions.}
\item{\code{median}, \code{signature(x = "Dirac")}:}{
@@ -403,6 +419,8 @@
exact evaluation using explicit expressions.}
\item{\code{median}, \code{signature(x = "Unif")}:}{
exact evaluation using explicit expressions.}
+ \item{\code{median}, \code{signature(x = "Arcsine")}:}{
+ exact evaluation using explicit expressions.}
\item{\code{mad}, \code{signature(x = "Cauchy")}:}{
exact evaluation using explicit expressions.}
\item{\code{mad}, \code{signature(x = "Dirac")}:}{
@@ -419,6 +437,8 @@
exact evaluation using explicit expressions.}
\item{\code{mad}, \code{signature(x = "Unif")}:}{
exact evaluation using explicit expressions.}
+ \item{\code{mad}, \code{signature(x = "Arcsine")}:}{
+ exact evaluation using explicit expressions.}
\item{\code{skewness}, \code{signature(x = "Beta")}:}{
for noncentrality 0 exact evaluation using explicit expressions.}
\item{\code{skewness}, \code{signature(x = "Binom")}:}{
@@ -457,6 +477,8 @@
exact evaluation using explicit expressions.}
\item{\code{skewness}, \code{signature(x = "Weibull")}:}{
exact evaluation using explicit expressions.}
+ \item{\code{skewness}, \code{signature(x = "Arcsine")}:}{
+ exact evaluation using explicit expressions.}
\item{\code{kurtosis}, \code{signature(x = "Beta")}:}{
for noncentrality 0 exact evaluation using explicit expressions.}
\item{\code{kurtosis}, \code{signature(x = "Binom")}:}{
@@ -495,6 +517,8 @@
exact evaluation using explicit expressions.}
\item{\code{kurtosis}, \code{signature(x = "Weibull")}:}{
exact evaluation using explicit expressions.}
+ \item{\code{kurtosis}, \code{signature(x = "Arcsine")}:}{
+ exact evaluation using explicit expressions.}
}}
%\references{ ~put references to the literature/web site here ~ }
More information about the Distr-commits
mailing list