[Robast-commits] r185 - branches/robast-0.7/pkg/RandVar/R pkg/RandVar/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Oct 29 20:39:05 CET 2008
Author: ruckdeschel
Date: 2008-10-29 20:39:04 +0100 (Wed, 29 Oct 2008)
New Revision: 185
Modified:
branches/robast-0.7/pkg/RandVar/R/util.R
pkg/RandVar/R/util.R
Log:
breakthrough (for roptest) : change in util.R to quickly compute image distribution of DiscreteDistribution
Modified: branches/robast-0.7/pkg/RandVar/R/util.R
===================================================================
--- branches/robast-0.7/pkg/RandVar/R/util.R 2008-10-29 18:26:14 UTC (rev 184)
+++ branches/robast-0.7/pkg/RandVar/R/util.R 2008-10-29 19:39:04 UTC (rev 185)
@@ -1,6 +1,8 @@
## small util if imageDistr fails
.getImageDistr <- function(f, distr)
-{ if (is(try(return(f(distr)), silent = TRUE),
+{ if (is(distr, "DiscreteDistribution"))
+ return(DiscreteDistribution(prob=d(distr)(support(distr)), supp=f(support(distr))))
+ if (is(try(return(f(distr)), silent = TRUE),
"try-error")){
rl <- function(n) { xr <- r(distr)(n); f(xr) }
return(AbscontDistribution( r = rl, .withArith = TRUE, .withSim = TRUE))}
Modified: pkg/RandVar/R/util.R
===================================================================
--- pkg/RandVar/R/util.R 2008-10-29 18:26:14 UTC (rev 184)
+++ pkg/RandVar/R/util.R 2008-10-29 19:39:04 UTC (rev 185)
@@ -1,6 +1,8 @@
## small util if imageDistr fails
.getImageDistr <- function(f, distr)
-{ if (is(try(return(f(distr)), silent = TRUE),
+{ if (is(distr, "DiscreteDistribution"))
+ return(DiscreteDistribution(prob=d(distr)(support(distr)), supp=f(support(distr))))
+ if (is(try(return(f(distr)), silent = TRUE),
"try-error")){
rl <- function(n) { xr <- r(distr)(n); f(xr) }
return(AbscontDistribution( r = rl, .withArith = TRUE, .withSim = TRUE))}
More information about the Robast-commits
mailing list