[Distr-commits] r412 - in branches/distr-2.1/pkg: distr/chm distrEx distrEx/R distrEx/chm distrEx/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 17 20:19:49 CET 2009
Author: ruckdeschel
Date: 2009-03-17 20:19:49 +0100 (Tue, 17 Mar 2009)
New Revision: 412
Added:
branches/distr-2.1/pkg/distrEx/R/OAsymTotalVarDist.R
branches/distr-2.1/pkg/distrEx/chm/OAsymTotalVarDist.html
branches/distr-2.1/pkg/distrEx/man/OAsymTotalVarDist.Rd
Modified:
branches/distr-2.1/pkg/distr/chm/Distr.chm
branches/distr-2.1/pkg/distrEx/NAMESPACE
branches/distr-2.1/pkg/distrEx/R/AllGeneric.R
branches/distr-2.1/pkg/distrEx/chm/00Index.html
branches/distr-2.1/pkg/distrEx/chm/distrEx.chm
branches/distr-2.1/pkg/distrEx/chm/distrEx.hhp
branches/distr-2.1/pkg/distrEx/chm/distrEx.toc
Log:
introduced distance OAsymTotalVarDist --- the minimal asymmetric total variation distance defined as
d_v'(P,Q)=\min_{c\ge 0} \int |dQ - c\, dP|
this gives the minimal asymmetric TotalVarDist, i.e. for "optimal" \rho = \int (dQ - c\, dP)_ / \int (dQ - c\, dP)_+
Claudio Agostinelli defines this distance to simultaneously treat inliers (missing generators; negative part of the integrand)
and outliers (positive part of the integrand)...
Corresponding MDEs are now available...
Modified: branches/distr-2.1/pkg/distr/chm/Distr.chm
===================================================================
(Binary files differ)
Modified: branches/distr-2.1/pkg/distrEx/NAMESPACE
===================================================================
--- branches/distr-2.1/pkg/distrEx/NAMESPACE 2009-03-17 16:40:29 UTC (rev 411)
+++ branches/distr-2.1/pkg/distrEx/NAMESPACE 2009-03-17 19:19:49 UTC (rev 412)
@@ -21,6 +21,7 @@
"ContaminationSize",
"TotalVarDist",
"AsymTotalVarDist",
+ "OAsymTotalVarDist",
"KolmogorovDist",
"HellingerDist",
"CvMDist")
Modified: branches/distr-2.1/pkg/distrEx/R/AllGeneric.R
===================================================================
--- branches/distr-2.1/pkg/distrEx/R/AllGeneric.R 2009-03-17 16:40:29 UTC (rev 411)
+++ branches/distr-2.1/pkg/distrEx/R/AllGeneric.R 2009-03-17 19:19:49 UTC (rev 412)
@@ -141,6 +141,10 @@
setGeneric("AsymTotalVarDist",
function(e1, e2, ...) standardGeneric("AsymTotalVarDist"))
}
+if(!isGeneric("OAsymTotalVarDist")){
+ setGeneric("OAsymTotalVarDist",
+ function(e1, e2, ...) standardGeneric("OAsymTotalVarDist"))
+}
if(!isGeneric("E")){
setGeneric("E", function(object, fun, cond, ...) standardGeneric("E"))
Added: branches/distr-2.1/pkg/distrEx/R/OAsymTotalVarDist.R
===================================================================
--- branches/distr-2.1/pkg/distrEx/R/OAsymTotalVarDist.R (rev 0)
+++ branches/distr-2.1/pkg/distrEx/R/OAsymTotalVarDist.R 2009-03-17 19:19:49 UTC (rev 412)
@@ -0,0 +1,298 @@
+###############################################################################
+## Method: OAsymOAsymTotalVarDist
+## asymmetric total variation distance of two distributions
+##
+## newly introduced by P.R. 13 03 09 --- for use in collaboration with
+## Matthias Brandl, Claudio Agostinelli
+##
+###############################################################################
+setMethod("OAsymTotalVarDist", signature(e1 = "AbscontDistribution",
+ e2 = "AbscontDistribution"),
+ function(e1, e2,
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15){
+
+ ## if we have to recall this method with a smaller TruncQuantile arg:
+ mc <- as.list(match.call(call = sys.call(sys.parent(1)))[-1])
+ mc$TruncQuantile <- TruncQuantile * 1.8
+
+ #block warnings:
+ o.warn <- getOption("warn"); options(warn = -1)
+ on.exit(options(warn=o.warn))
+
+ ## find sensible lower and upper bounds for integration of q-cp
+ # (a) quantile based
+ low <- min(getLow(e1, eps = TruncQuantile), getLow(e2, eps = TruncQuantile))
+ up <- max(getUp(e1, eps = TruncQuantile), getUp(e2, eps = TruncQuantile))
+ # (b) scale based
+ s0 <- min(IQR(e1),IQR(e2))*IQR.fac
+ low0 <- min(median(e1),median(e2))-s0
+ up0 <- max(median(e1),median(e2))+s0
+ # (a) & (b)
+ low <- max(low,low0); up <- min(up,up0)
+ #
+ # store densities to avoid dispatch
+ d1 <- d(e1); d2 <- d(e2)
+ #
+ ### integration as a function of c:
+ Eip <- function(f, c00)
+ distrExIntegrate(f, lower = low, upper = up,
+ rel.tol = rel.tol, c00 = c00)
+ integ <- function(x,c00) abs(d2(x)-c00*d1(x))
+
+ fct <- function(c0) Eip(f=integ, c00=c0)
+
+ ## find sensible search range for c-values
+ ## goal: range of density quotient d2(x)/d1(x)
+ ## x-range:
+ x.range <- seq(low, up, length=Ngrid/3)
+ x.range <- c(x.range, q(e1)(seq(TruncQuantile,1-TruncQuantile,length=Ngrid/3)))
+ x.range <- c(x.range, q(e2)(seq(TruncQuantile,1-TruncQuantile,length=Ngrid/3)))
+ ## to avoid division by 0:
+ d1x.range <- d10x.range <- d1(x.range)
+ d1x.range <- d1x.range+(d1x.range<1e-20)
+ ## bound dx.range from 0 and from maximal value:
+ d2x.range <- d2(x.range)
+ dx.range <- (d2x.range/d1x.range*(d10x.range>=1e-10)+
+ d2x.range*1e10*(d10x.range<1e-10))*.9999999+1e-10
+ ## gives range for c:
+ low1 <- min(dx.range); up1 <- max(dx.range)
+
+ c.opt <- try(optimize(fct, lower = low1, upper = up1,
+ tol = rel.tol)$minimum,
+ silent = TRUE)
+
+ ## if does not give reasonable solution recall function with
+ # smaller TruncQuantile
+ if(!is.numeric(c.opt))
+ return(do.call(getMethod("OAsymTotalVarDist",
+ signature(e1 = "AbscontDistribution",
+ e2 = "AbscontDistribution")),
+ args = mc))
+ ## else:
+ res <- Eip(f=integ, c00=c.opt)
+ names(res) <- "minimal asym. total variation distance"
+ return(res)
+ })
+
+setMethod("OAsymTotalVarDist", signature(e1 = "DiscreteDistribution",
+ e2 = "DiscreteDistribution"),
+ function(e1, e2, ...){
+ o.warn <- getOption("warn"); options(warn = -1)
+ on.exit(options(warn=o.warn))
+ supp <- union(support(e1), support(e2))
+ # store densities to avoid dispatch
+ d1 <- d(e1); d2 <- d(e2)
+
+ d2.range <- d2(supp)
+ d1.range <- d1(supp)
+
+ integ <- function(c00) abs(d2.range-c00*d1.range)
+
+ fct <- function(c0) sum(integ(c0))
+
+ d10.range <- d1.range
+ d1e.range <- d1.range+(d1.range<1e-10)
+ ## bound dx.range from 0 and from maximal value:
+ d.range <- (d2.range/d1e.range*(d10.range>=1e-10)+
+ d2.range*1e10*(d10.range<1e-10))*.99999999+1e-10
+ ## gives range for c:
+ low1 <- min(d.range); up1 <- max(d.range)
+
+
+ c.opt <- optimize(fct, lower=low1, upper=up1)$minimum
+ res <- sum(integ(c.opt))
+ names(res) <- "minimal asym. total variation distance"
+ return(res)
+ })
+setMethod("OAsymTotalVarDist", signature(e1 = "DiscreteDistribution",
+ e2 = "AbscontDistribution"),
+ function(e1, e2, ...){
+ res <- 1
+ names(res) <- "minimal asym. total variation distance"
+
+ return(res)
+ })
+setMethod("OAsymTotalVarDist", signature(e1 = "AbscontDistribution",
+ e2 = "DiscreteDistribution"),
+ function(e1, e2, ...){
+ res <- 1
+ names(res) <- "minimal asym. total variation distance"
+
+ return(res)
+ })
+setMethod("OAsymTotalVarDist", signature(e1 = "numeric",
+ e2 = "DiscreteDistribution"),
+ function(e1, e2, ...){
+ t1 <- table(e1)
+ d1 <- t1/length(e1)
+ s1 <- as.numeric(names(t1))
+ e11 <- DiscreteDistribution(supp=s1, prob=d1)
+ return(OAsymTotalVarDist(e11,e2, ...))
+ })
+
+setMethod("OAsymTotalVarDist", signature(e1 = "DiscreteDistribution",
+ e2 = "numeric"),
+ function(e1, e2, ...){
+ return(OAsymTotalVarDist(e2, e1, ...))
+ })
+
+## to avoid trivial distances (distance = 1)
+## abs.cont. distributions may be discretized
+## resp. empirical distributions may be smoothed
+## (by convolution with a normal distribution)
+setMethod("OAsymTotalVarDist", signature(e1 = "numeric",
+ e2 = "AbscontDistribution"),
+ function(e1, e2, asis.smooth.discretize = "discretize", n.discr =
+ getdistrExOption("nDiscretize"), low.discr = getLow(e2),
+ up.discr = getUp(e2), h.smooth = getdistrExOption("hSmooth"),
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15){
+ .asis.smooth.discretize.distance(e1, e2, asis.smooth.discretize, n.discr,
+ low.discr, up.discr, h.smooth, OAsymTotalVarDist,
+ rel.tol = rel.tol, Ngrid = Ngrid,
+ TruncQuantile = TruncQuantile, IQR.fac = IQR.fac)
+ })
+setMethod("OAsymTotalVarDist", signature(e1 = "AbscontDistribution",
+ e2 = "numeric"),
+ function(e1, e2, asis.smooth.discretize = "discretize", n.discr =
+ getdistrExOption("nDiscretize"), low.discr = getLow(e1),
+ up.discr = getUp(e1), h.smooth = getdistrExOption("hSmooth"),
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15){
+ return(OAsymTotalVarDist(e2, e1,
+ asis.smooth.discretize = asis.smooth.discretize,
+ low.discr = low.discr, up.discr = up.discr, h.smooth = h.smooth,
+ rel.tol = rel.tol, Ngrid = Ngrid,
+ TruncQuantile = TruncQuantile, IQR.fac = IQR.fac))
+ })
+
+setMethod("OAsymTotalVarDist", signature(e1 = "AcDcLcDistribution",
+ e2 = "AcDcLcDistribution"),
+ function(e1, e2,
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15){
+ ## if we have to recall this method with a smaller TruncQuantile arg:
+ mc <- as.list(match.call(call = sys.call(sys.parent(1)))[-1])
+ mc$TruncQuantile <- TruncQuantile * 1.8
+
+ #block warnings:
+ o.warn <- getOption("warn"); options(warn = -1)
+ on.exit(options(warn=o.warn))
+
+ if( is(e1,"AbscontDistribution"))
+ e1 <- as(as(e1,"AbscontDistribution"), "UnivarLebDecDistribution")
+ if( is(e2,"AbscontDistribution"))
+ e2 <- as(as(e2,"AbscontDistribution"), "UnivarLebDecDistribution")
+ if(is(e1,"DiscreteDistribution"))
+ e1 <- as(as(e1,"DiscreteDistribution"), "UnivarLebDecDistribution")
+ if(is(e2,"DiscreteDistribution"))
+ e2 <- as(as(e2,"DiscreteDistribution"), "UnivarLebDecDistribution")
+
+ ac1 <- acPart(e1); ac2 <- acPart(e2)
+ ac1d <- ac1 at d; ac2d <- ac2 at d
+ ac1.d <- function(x) ac1d(x)*acWeight(e1)
+ ac2.d <- function(x) ac2d(x)*acWeight(e2)
+
+ dc1 <- discretePart(e1); dc2 <- discretePart(e2)
+ dc1d <- dc1 at d; dc2d <- dc2 at d
+ dc1.d <- function(x) dc1d(x)*discreteWeight(e1)
+ dc2.d <- function(x) dc2d(x)*discreteWeight(e2)
+
+ ### continuous part
+
+ ## find sensible lower and upper bounds for integration of q-cp
+ # (a) quantile based
+ low <- min(getLow(ac1, eps = TruncQuantile), getLow(ac2, eps = TruncQuantile))
+ up <- max(getUp(ac1, eps = TruncQuantile), getUp(ac2, eps = TruncQuantile))
+ # (b) scale based
+ s0 <- min(IQR(ac1),IQR(ac2))*IQR.fac
+ low0 <- min(median(ac1),median(ac2))-s0
+ up0 <- max(median(ac1),median(ac2))+s0
+ # (a) & (b)
+ low <- max(low,low0); up <- min(up,up0)
+ #
+ ### integration as a function of c:
+ Eip <- function(f, c00)
+ distrExIntegrate(f, lower = low, upper = up,
+ rel.tol = rel.tol, c00 = c00)
+ integ.c <- function(x,c00) abs(ac2.d(x)-c00*ac1.d(x))
+
+ ### discrete part
+
+ supp <- union(support(dc1), support(dc2))
+
+ d2.range <- dc2.d(supp)
+ d1.range <- dc1.d(supp)
+
+ integ.d <- function(c00) abs(d2.range-c00*d1.range)
+
+
+ fct <- function(c0){
+ e.c <- Eip(f=integ.c, c00=c0)
+ e.d <- sum(integ.d(c0))
+ return(e.d+e.c)
+ }
+
+ ## find sensible search range for c-values
+ ## goal: range of density quotient d2(x)/d1(x)
+
+ ### continuous part
+ ## x-range:
+ x.range <- seq(low, up, length=Ngrid/3)
+ x.range <- c(x.range, q(ac1)(seq(TruncQuantile,1-TruncQuantile,length=Ngrid/3)))
+ x.range <- c(x.range, q(ac2)(seq(TruncQuantile,1-TruncQuantile,length=Ngrid/3)))
+ ## to avoid division by 0:
+ d1x.range <- d10x.range <- ac1.d(x.range)
+ d1x.range <- d1x.range+(d1x.range<1e-20)
+ ## bound dx.range from 0 and from maximal value:
+ d2x.range <- ac2.d(x.range)
+ dx.range <- (d2x.range/d1x.range*(d10x.range>=1e-20)+
+ d2x.range*1e20*(d10x.range<1e-20))*.99+1e-5
+
+ ### discrete part
+ d10.range <- d1.range
+ d1e.range <- d1.range+(d1.range<1e-7)
+ ## bound dx.range from 0 and from maximal value:
+ d.range <- (d2.range/d1e.range*(d10.range>=1e-10)+
+ d2.range*1e10*(d10.range<1e-10))*.999999+1e-10
+
+ ## gives range for c:
+ low1 <- min(d.range,dx.range); up1 <- max(d.range,dx.range)
+
+ c.opt <- try(optimize(fct, lower = low1, upper = up1, tol = rel.tol)$minimum,
+ silent = TRUE)
+
+ ## if does not give reasonable solution recall function with
+ # smaller TruncQuantile
+ if(!is.numeric(c.opt)){
+ return(do.call(getMethod("OAsymTotalVarDist",
+ signature(e1 = "AcDcLcDistribution",
+ e2 = "AcDcLcDistribution")),
+ args = mc))
+ }
+ res <- Eip(f=integ.c, c00=c.opt)+sum(integ.d(c.opt))
+ names(res) <- "minimal asym. total variation distance"
+ return(res)
+ })
+
+setMethod("OAsymTotalVarDist", signature(e1 = "LatticeDistribution",
+ e2 = "LatticeDistribution"),
+ getMethod("OAsymTotalVarDist", signature(e1 = "DiscreteDistribution",
+ e2 = "DiscreteDistribution")))
+
+setMethod("OAsymTotalVarDist", signature(e1 = "LatticeDistribution",
+ e2 = "DiscreteDistribution"),
+ getMethod("OAsymTotalVarDist", signature(e1 = "DiscreteDistribution",
+ e2 = "DiscreteDistribution")))
+
+setMethod("OAsymTotalVarDist", signature(e1 = "DiscreteDistribution",
+ e2 = "LatticeDistribution"),
+ getMethod("OAsymTotalVarDist", signature(e1 = "DiscreteDistribution",
+ e2 = "DiscreteDistribution")))
+
+
Modified: branches/distr-2.1/pkg/distrEx/chm/00Index.html
===================================================================
--- branches/distr-2.1/pkg/distrEx/chm/00Index.html 2009-03-17 16:40:29 UTC (rev 411)
+++ branches/distr-2.1/pkg/distrEx/chm/00Index.html 2009-03-17 19:19:49 UTC (rev 412)
@@ -26,6 +26,7 @@
<a href="#L">L</a>
<a href="#M">M</a>
<a href="#N">N</a>
+<a href="#O">O</a>
<a href="#P">P</a>
<a href="#R">R</a>
<a href="#S">S</a>
@@ -642,6 +643,39 @@
<td>Function to change the global variables of the package 'distrEx'</td></tr>
</table>
+<h2><a name="O">-- O --</a></h2>
+
+<table width="100%">
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,AbscontDistribution,AbscontDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,AbscontDistribution,DiscreteDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,AbscontDistribution,numeric-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,AcDcLcDistribution,AcDcLcDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,DiscreteDistribution,AbscontDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,DiscreteDistribution,DiscreteDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,DiscreteDistribution,LatticeDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,DiscreteDistribution,numeric-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,LatticeDistribution,DiscreteDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,LatticeDistribution,LatticeDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,numeric,AbscontDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist,numeric,DiscreteDistribution-method</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+<tr><td width="25%"><a href="OAsymTotalVarDist.html">OAsymTotalVarDist-methods</a></td>
+<td>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</td></tr>
+</table>
+
<h2><a name="P">-- P --</a></h2>
<table width="100%">
Added: branches/distr-2.1/pkg/distrEx/chm/OAsymTotalVarDist.html
===================================================================
--- branches/distr-2.1/pkg/distrEx/chm/OAsymTotalVarDist.html (rev 0)
+++ branches/distr-2.1/pkg/distrEx/chm/OAsymTotalVarDist.html 2009-03-17 19:19:49 UTC (rev 412)
@@ -0,0 +1,280 @@
+<html><head><title>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" type="text/css" href="Rchm.css">
+</head>
+<body>
+
+<table width="100%"><tr><td>OAsymTotalVarDist(distrEx)</td><td align="right">R Documentation</td></tr></table><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
+<param name="keyword" value="R: OAsymTotalVarDist">
+<param name="keyword" value="R: OAsymTotalVarDist-methods">
+<param name="keyword" value="R: OAsymTotalVarDist,AbscontDistribution,AbscontDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,AbscontDistribution,DiscreteDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,DiscreteDistribution,DiscreteDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,DiscreteDistribution,AbscontDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,LatticeDistribution,DiscreteDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,DiscreteDistribution,LatticeDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,LatticeDistribution,LatticeDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,numeric,DiscreteDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,DiscreteDistribution,numeric-method">
+<param name="keyword" value="R: OAsymTotalVarDist,numeric,AbscontDistribution-method">
+<param name="keyword" value="R: OAsymTotalVarDist,AbscontDistribution,numeric-method">
+<param name="keyword" value="R: OAsymTotalVarDist,AcDcLcDistribution,AcDcLcDistribution-method">
+<param name="keyword" value=" Generic function for the computation of (minimal) asymmetric total variation distance of two distributions">
+</object>
+
+
+<h2>Generic function for the computation of (minimal) asymmetric total variation distance of two distributions</h2>
+
+
+<h3>Description</h3>
+
+<p>
+Generic function for the computation of (minimal) asymmetric total variation distance
+<i>d_v'</i>
+of two distributions <i>P</i> and <i>Q</i> where the distributions may be
+defined for an arbitrary sample space <i>(Omega, A)</i>.
+This distance is defined as
+</p><p align="center"><i>d_v(rho)(P,Q)=min_c int |(dQ-c dP|</i></p>
+
+
+<h3>Usage</h3>
+
+<pre>
+OAsymTotalVarDist(e1, e2, ...)
+## S4 method for signature 'AbscontDistribution,
+## AbscontDistribution':
+OAsymTotalVarDist(e1,e2,
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15)
+## S4 method for signature 'AbscontDistribution,
+## DiscreteDistribution':
+OAsymTotalVarDist(e1,e2, ...)
+## S4 method for signature 'DiscreteDistribution,
+## AbscontDistribution':
+OAsymTotalVarDist(e1,e2, ...)
+## S4 method for signature 'DiscreteDistribution,
+## DiscreteDistribution':
+OAsymTotalVarDist(e1,e2, ...)
+## S4 method for signature 'numeric, DiscreteDistribution':
+OAsymTotalVarDist(e1, e2, ...)
+## S4 method for signature 'DiscreteDistribution, numeric':
+OAsymTotalVarDist(e1, e2, ...)
+## S4 method for signature 'numeric, AbscontDistribution':
+OAsymTotalVarDist(e1, e2, asis.smooth.discretize = "discretize",
+ n.discr = getdistrExOption("nDiscretize"), low.discr = getLow(e2),
+ up.discr = getUp(e2), h.smooth = getdistrExOption("hSmooth"),
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15)
+## S4 method for signature 'AbscontDistribution, numeric':
+OAsymTotalVarDist(e1, e2,
+ asis.smooth.discretize = "discretize",
+ n.discr = getdistrExOption("nDiscretize"), low.discr = getLow(e1),
+ up.discr = getUp(e1), h.smooth = getdistrExOption("hSmooth"),
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15)
+## S4 method for signature 'AcDcLcDistribution,
+## AcDcLcDistribution':
+OAsymTotalVarDist(e1, e2,
+ rel.tol = .Machine$double.eps^0.3, Ngrid = 10000,
+ TruncQuantile = getdistrOption("TruncQuantile"),
+ IQR.fac = 15)
+</pre>
+
+
+<h3>Arguments</h3>
+
+<table summary="R argblock">
+<tr valign="top"><td><code>e1</code></td>
+<td>
+object of class <code>"Distribution"</code> or <code>"numeric"</code> </td></tr>
+<tr valign="top"><td><code>e2</code></td>
+<td>
+object of class <code>"Distribution"</code> or <code>"numeric"</code> </td></tr>
+<tr valign="top"><td><code>asis.smooth.discretize</code></td>
+<td>
+possible methods are <code>"asis"</code>,
+<code>"smooth"</code> and <code>"discretize"</code>. Default is <code>"discretize"</code>.</td></tr>
+<tr valign="top"><td><code>n.discr</code></td>
+<td>
+if <code>asis.smooth.discretize</code> is equal to
+<code>"discretize"</code> one has to specify the number of lattice points
+used to discretize the abs. cont. distribution.</td></tr>
+<tr valign="top"><td><code>low.discr</code></td>
+<td>
+if <code>asis.smooth.discretize</code> is equal to
+<code>"discretize"</code> one has to specify the lower end point of the lattice
+used to discretize the abs. cont. distribution.</td></tr>
+<tr valign="top"><td><code>up.discr</code></td>
+<td>
+if <code>asis.smooth.discretize</code> is equal to
+<code>"discretize"</code> one has to specify the upper end point of the lattice
+used to discretize the abs. cont. distribution.</td></tr>
+<tr valign="top"><td><code>h.smooth</code></td>
+<td>
+if <code>asis.smooth.discretize</code> is equal to
+<code>"smooth"</code> – i.e., the empirical distribution of the provided
+data should be smoothed – one has to specify this parameter.</td></tr>
+<tr valign="top"><td><code>rel.tol</code></td>
+<td>
+relative tolerance for <code>distrExIntegrate</code> and <code>uniroot</code></td></tr>
+<tr valign="top"><td><code>Ngrid</code></td>
+<td>
+How many grid points are to be evaluated to determine the range
+of the likelihood ratio?</td></tr>
+<tr valign="top"><td><code>TruncQuantile</code></td>
+<td>
+Quantile the quantile based integration bounds (see details)</td></tr>
+<tr valign="top"><td><code>IQR.fac</code></td>
+<td>
+Factor for the scale based integration bounds (see details)</td></tr>
+<tr valign="top"><td><code>...</code></td>
+<td>
+further arguments to be used in particular methods (not in package <span class="pkg">distrEx</span>)</td></tr>
+</table>
+
+<h3>Details</h3>
+
+<p>
+For distances between absolutely continuous distributions, we use numerical
+integration; to determine sensible bounds we proceed as follows:
+by means of <code>min(getLow(e1,eps=TruncQuantile),getLow(e2,eps=TruncQuantile))</code>,
+<code>max(getUp(e1,eps=TruncQuantile),getUp(e2,eps=TruncQuantile))</code> we determine
+quantile based bounds <code>c(low.0,up.0)</code>, and by means of
+<code>s1 <- max(IQR(e1),IQR(e2));</code> <code>m1<- median(e1);</code>
+<code>m2 <- median(e2)</code>
+and <code>low.1 <- min(m1,m2)-s1*IQR.fac</code>, <code>up.1 <- max(m1,m2)+s1*IQR.fac</code>
+we determine scale based bounds; these are combined by
+<code>low <- max(low.0,low.1)</code>, <code>up <- max(up.0,up1)</code>.
+</p>
+<p>
+Again in the absolutely continuous case, to determine the range of the
+likelihood ratio, we evaluate this ratio on a grid constructed as follows:
+<code>x.range <- c(seq(low, up, length=Ngrid/3),
+ q(e1)(seq(0,1,length=Ngrid/3)*.999),
+ q(e2)(seq(0,1,length=Ngrid/3)*.999))</code>
+</p>
+<p>
+Finally, for both discrete and absolutely continuous case,
+we clip this ratio downwards by <code>1e-10</code> and upwards by <code>1e10</code>
+</p>
+<p>
+In case we want to compute the total variation distance between (empirical) data
+and an abs. cont. distribution, we can specify the parameter <code>asis.smooth.discretize</code>
+to avoid trivial distances (distance = 1).
+</p>
+<p>
+Using <code>asis.smooth.discretize = "discretize"</code>, which is the default,
+leads to a discretization of the provided abs. cont. distribution and
+the distance is computed between the provided data and the discretized
+distribution.
+</p>
+<p>
+Using <code>asis.smooth.discretize = "smooth"</code> causes smoothing of the
+empirical distribution of the provided data. This is, the empirical
+data is convoluted with the normal distribution <code>Norm(mean = 0, sd = h.smooth)</code>
+which leads to an abs. cont. distribution. Afterwards the distance
+between the smoothed empirical distribution and the provided abs. cont.
+distribution is computed.
+</p>
+
+
+<h3>Value</h3>
+
+<p>
+OAsymmetric Total variation distance of <code>e1</code> and <code>e2</code></p>
+
+<h3>Methods</h3>
+
+<dl>
+<dt>e1 = "AbscontDistribution", e2 = "AbscontDistribution":</dt><dd>total variation distance of two absolutely continuous
+univariate distributions which is computed using <code>distrExIntegrate</code>.
+</dd>
+<dt>e1 = "AbscontDistribution", e2 = "DiscreteDistribution":</dt><dd>total variation distance of absolutely continuous and discrete
+univariate distributions (are mutually singular; i.e.,
+have distance <code>=1</code>).
+</dd>
+<dt>e1 = "DiscreteDistribution", e2 = "DiscreteDistribution":</dt><dd>total variation distance of two discrete univariate distributions
+which is computed using <code>support</code> and <code>sum</code>.
+</dd>
+<dt>e1 = "DiscreteDistribution", e2 = "AbscontDistribution":</dt><dd>total variation distance of discrete and absolutely continuous
+univariate distributions (are mutually singular; i.e.,
+have distance <code>=1</code>).
+</dd>
+<dt>e1 = "numeric", e2 = "DiscreteDistribution":</dt><dd>Total variation distance between (empirical) data and a discrete
+distribution.
+</dd>
+<dt>e1 = "DiscreteDistribution", e2 = "numeric":</dt><dd>Total variation distance between (empirical) data and a discrete
+distribution.
+</dd>
+<dt>e1 = "numeric", e2 = "AbscontDistribution":</dt><dd>Total variation distance between (empirical) data and an abs. cont.
+distribution.
+</dd>
+<dt>e1 = "AbscontDistribution", e1 = "numeric":</dt><dd>Total variation distance between (empirical) data and an abs. cont.
+distribution.
+</dd>
+<dt>e1 = "AcDcLcDistribution", e2 = "AcDcLcDistribution":</dt><dd>Total variation distance of mixed discrete and absolutely continuous
+univariate distributions.
+</dd>
+</dl>
+
+<h3>Author(s)</h3>
+
+<p>
+Peter Ruckdeschel <a href="mailto:Peter.Ruckdeschel at itwm.fraunhofer.de">Peter.Ruckdeschel at itwm.fraunhofer.de</a>
+</p>
+
+
+<h3>References</h3>
+
+<p>
+to be filled;
+Agostinelli, C and Ruckdeschel, P. (2009): A simultaneous inlier and outlier model
+by asymmetric total variation distance.
+</p>
+
+
+<h3>See Also</h3>
+
+<p>
+<code><a href="TotalVarDist.html">TotalVarDist-methods</a></code>, <code><a href="ContaminationSize.html">ContaminationSize</a></code>,
+<code><a href="KolmogorovDist.html">KolmogorovDist</a></code>, <code><a href="HellingerDist.html">HellingerDist</a></code>,
+<code><a onclick="findlink('distr', 'Distribution-class.html')" style="text-decoration: underline; color: blue; cursor: hand">Distribution-class</a></code>
+</p>
+
+
+<h3>Examples</h3>
+
+<pre>
+OAsymTotalVarDist(Norm(), Gumbel())
+OAsymTotalVarDist(Norm(), Td(10))
+OAsymTotalVarDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100)) # mutually singular
+OAsymTotalVarDist(Pois(10), Binom(size = 20))
+
+x <- rnorm(100)
+OAsymTotalVarDist(Norm(), x)
+OAsymTotalVarDist(x, Norm(), asis.smooth.discretize = "smooth")
+
+y <- (rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5)
+OAsymTotalVarDist(y, Norm())
+OAsymTotalVarDist(y, Norm(), asis.smooth.discretize = "smooth")
+
+OAsymTotalVarDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5))
+</pre>
+
+<script Language="JScript">
+function findlink(pkg, fn) {
+var Y, link;
+Y = location.href.lastIndexOf("\\") + 1;
+link = location.href.substring(0, Y);
+link = link + "../../" + pkg + "/chtml/" + pkg + ".chm::/" + fn;
+location.href = link;
+}
+</script>
+
+
+<hr><div align="center">[Package <em>distrEx</em> version 2.1 <a href="00Index.html">Index</a>]</div>
+
+</body></html>
Modified: branches/distr-2.1/pkg/distrEx/chm/distrEx.chm
===================================================================
(Binary files differ)
Modified: branches/distr-2.1/pkg/distrEx/chm/distrEx.hhp
===================================================================
--- branches/distr-2.1/pkg/distrEx/chm/distrEx.hhp 2009-03-17 16:40:29 UTC (rev 411)
+++ branches/distr-2.1/pkg/distrEx/chm/distrEx.hhp 2009-03-17 19:19:49 UTC (rev 412)
@@ -35,6 +35,7 @@
LMParameter-class.html
LMParameter.html
MultivariateDistribution-class.html
+OAsymTotalVarDist.html
PrognCondDistribution-class.html
PrognCondition-class.html
TotalVarDist.html
Modified: branches/distr-2.1/pkg/distrEx/chm/distrEx.toc
===================================================================
--- branches/distr-2.1/pkg/distrEx/chm/distrEx.toc 2009-03-17 16:40:29 UTC (rev 411)
+++ branches/distr-2.1/pkg/distrEx/chm/distrEx.toc 2009-03-17 19:19:49 UTC (rev 412)
@@ -1094,6 +1094,62 @@
<param name="Local" value="distrExOptions.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
+<param name="Name" value="OAsymTotalVarDist">
+<param name="Local" value="OAsymTotalVarDist.html">
+</OBJECT>
+<LI> <OBJECT type="text/sitemap">
+<param name="Name" value="OAsymTotalVarDist,AbscontDistribution,AbscontDistribution-method">
+<param name="Local" value="OAsymTotalVarDist.html">
+</OBJECT>
+<LI> <OBJECT type="text/sitemap">
+<param name="Name" value="OAsymTotalVarDist,AbscontDistribution,DiscreteDistribution-method">
+<param name="Local" value="OAsymTotalVarDist.html">
+</OBJECT>
+<LI> <OBJECT type="text/sitemap">
+<param name="Name" value="OAsymTotalVarDist,AbscontDistribution,numeric-method">
+<param name="Local" value="OAsymTotalVarDist.html">
+</OBJECT>
+<LI> <OBJECT type="text/sitemap">
+<param name="Name" value="OAsymTotalVarDist,AcDcLcDistribution,AcDcLcDistribution-method">
+<param name="Local" value="OAsymTotalVarDist.html">
+</OBJECT>
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/distr -r 412
More information about the Distr-commits
mailing list