[Distr-commits] r1129 - in branches/distr-2.7/pkg/distrEx: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Sep 8 08:56:36 CEST 2016
Author: ruckdeschel
Date: 2016-09-08 08:56:35 +0200 (Thu, 08 Sep 2016)
New Revision: 1129
Modified:
branches/distr-2.7/pkg/distrEx/R/HellingerDist.R
branches/distr-2.7/pkg/distrEx/R/TotalVarDist.R
branches/distr-2.7/pkg/distrEx/man/HellingerDist.Rd
branches/distr-2.7/pkg/distrEx/man/TotalVarDist.Rd
Log:
triggered by mail from Peng Rui, larodarchillwind at aliyun.com, implemented
Hellinger and TotalVariation distance for DiscreteMVDistributions
Modified: branches/distr-2.7/pkg/distrEx/R/HellingerDist.R
===================================================================
--- branches/distr-2.7/pkg/distrEx/R/HellingerDist.R 2016-09-05 12:14:51 UTC (rev 1128)
+++ branches/distr-2.7/pkg/distrEx/R/HellingerDist.R 2016-09-08 06:56:35 UTC (rev 1129)
@@ -39,6 +39,25 @@
return(sqrt(res)) # ^.5 added P.R. 19-12-06
})
+
+## new PR 08-09-16
+setMethod("HellingerDist", signature(e1 = "DiscreteMVDistribution",
+ e2 = "DiscreteMVDistribution"),
+ function(e1, e2, ...){
+ o.warn <- getOption("warn"); options(warn = -1)
+ on.exit(options(warn=o.warn))
+ ## replace univariate line supp <- union(support(e1), support(e2)) by
+
+ supp <- unique(rbind(support(e1), support(e2)))
+
+
+ res <- 0.5*sum((sqrt(d(e1)(supp))-sqrt(d(e2)(supp)))^2)
+ names(res) <- "Hellinger distance"
+
+ return(sqrt(res))
+ })
+
+
setMethod("HellingerDist", signature(e1 = "DiscreteDistribution",
e2 = "AbscontDistribution"),
function(e1, e2, ...){
Modified: branches/distr-2.7/pkg/distrEx/R/TotalVarDist.R
===================================================================
--- branches/distr-2.7/pkg/distrEx/R/TotalVarDist.R 2016-09-05 12:14:51 UTC (rev 1128)
+++ branches/distr-2.7/pkg/distrEx/R/TotalVarDist.R 2016-09-08 06:56:35 UTC (rev 1129)
@@ -39,6 +39,23 @@
return(res)
})
+
+## new PR 08-09-16
+setMethod("TotalVarDist", signature(e1 = "DiscreteMVDistribution",
+ e2 = "DiscreteMVDistribution"),
+ function(e1, e2, ...){
+ o.warn <- getOption("warn"); options(warn = -1)
+ on.exit(options(warn=o.warn))
+ ## replace univariate line supp <- union(support(e1), support(e2)) by
+
+ supp <- unique(rbind(support(e1), support(e2)))
+
+ res <- 0.5*sum(abs(d(e1)(supp)-d(e2)(supp)))
+ names(res) <- "total variation distance"
+
+ return(res)
+ })
+
setMethod("TotalVarDist", signature(e1 = "DiscreteDistribution",
e2 = "AbscontDistribution"),
function(e1, e2, ...){
Modified: branches/distr-2.7/pkg/distrEx/man/HellingerDist.Rd
===================================================================
--- branches/distr-2.7/pkg/distrEx/man/HellingerDist.Rd 2016-09-05 12:14:51 UTC (rev 1128)
+++ branches/distr-2.7/pkg/distrEx/man/HellingerDist.Rd 2016-09-08 06:56:35 UTC (rev 1129)
@@ -4,6 +4,7 @@
\alias{HellingerDist,AbscontDistribution,AbscontDistribution-method}
\alias{HellingerDist,AbscontDistribution,DiscreteDistribution-method}
\alias{HellingerDist,DiscreteDistribution,DiscreteDistribution-method}
+\alias{HellingerDist,DiscreteMVDistribution,DiscreteMVDistribution-method}
\alias{HellingerDist,DiscreteDistribution,AbscontDistribution-method}
\alias{HellingerDist,LatticeDistribution,DiscreteDistribution-method}
\alias{HellingerDist,DiscreteDistribution,LatticeDistribution-method}
Modified: branches/distr-2.7/pkg/distrEx/man/TotalVarDist.Rd
===================================================================
--- branches/distr-2.7/pkg/distrEx/man/TotalVarDist.Rd 2016-09-05 12:14:51 UTC (rev 1128)
+++ branches/distr-2.7/pkg/distrEx/man/TotalVarDist.Rd 2016-09-08 06:56:35 UTC (rev 1129)
@@ -4,6 +4,7 @@
\alias{TotalVarDist,AbscontDistribution,AbscontDistribution-method}
\alias{TotalVarDist,AbscontDistribution,DiscreteDistribution-method}
\alias{TotalVarDist,DiscreteDistribution,DiscreteDistribution-method}
+\alias{TotalVarDist,DiscreteMVDistribution,DiscreteMVDistribution-method}
\alias{TotalVarDist,DiscreteDistribution,AbscontDistribution-method}
\alias{TotalVarDist,LatticeDistribution,DiscreteDistribution-method}
\alias{TotalVarDist,DiscreteDistribution,LatticeDistribution-method}
More information about the Distr-commits
mailing list