[Distr-commits] r806 - in branches/distr-2.4/pkg/distrEx: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed May 16 13:28:28 CEST 2012
Author: ruckdeschel
Date: 2012-05-16 13:28:28 +0200 (Wed, 16 May 2012)
New Revision: 806
Modified:
branches/distr-2.4/pkg/distrEx/R/SnQn.R
branches/distr-2.4/pkg/distrEx/man/Var.Rd
Log:
committed Sn functional for DiscreteDistribution objects
Modified: branches/distr-2.4/pkg/distrEx/R/SnQn.R
===================================================================
--- branches/distr-2.4/pkg/distrEx/R/SnQn.R 2012-05-15 17:03:53 UTC (rev 805)
+++ branches/distr-2.4/pkg/distrEx/R/SnQn.R 2012-05-16 11:28:28 UTC (rev 806)
@@ -61,6 +61,25 @@
return(c0)
})
+setMethod("Sn", signature(x = "DiscreteDistribution"),
+ function(x, ...){
+
+ g <- function(xx){
+ median(abs(x-xx))
+ }
+
+ pr <- prob(x)
+ sx <- support(x)
+ y <- sapply(sx,g)
+ o <- order(y)
+ yo <- y[o]
+ pro <- pr[o]
+ cpro <- cumsum(pro)
+ ws <- min(sum(which(cpro<0.5))+1,length(o))
+ return(yo[ws])
+ })
+
+
setMethod("Sn", signature(x = "Norm"),
function(x, ...){
return(sd(x)* 0.8385098038)
Modified: branches/distr-2.4/pkg/distrEx/man/Var.Rd
===================================================================
--- branches/distr-2.4/pkg/distrEx/man/Var.Rd 2012-05-15 17:03:53 UTC (rev 805)
+++ branches/distr-2.4/pkg/distrEx/man/Var.Rd 2012-05-16 11:28:28 UTC (rev 806)
@@ -330,6 +330,7 @@
Sn(x, ...)
\S4method{Sn}{ANY}(x, ...)
\S4method{Sn}{UnivariateDistribution}(x, low = 0, upp = 20, accuracy = 1000, ...)
+\S4method{Sn}{DiscreteDistribution}(x, ...)
\S4method{Sn}{AffLinDistribution}(x, ...)
\S4method{Sn}{Norm}(x, ...)
@@ -451,6 +452,8 @@
interface to the \pkg{robustbase}-function \code{Qn} --- see \code{\link[robustbase]{Sn}}.}
\item{\code{Sn}, \code{signature(x = "UnivariateDistribution")}:}{
Sn of univariate distributions using pseudo-random variables (Thx to N. Horbenko).}
+ \item{\code{Sn}, \code{signature(x = "DiscreteDistribution")}:}{
+ Sn of discrete distributions.}
\item{\code{Sn}, \code{signature(x = "AffLinDistribution")}:}{\code{abs(x at a) * Sn(x at X0)}}
\item{\code{var}, \code{signature(x = "Arcsine")}:}{
More information about the Distr-commits
mailing list