[Rcpp-commits] r3532 - in pkg/RcppSMC: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 20 01:30:13 CET 2012
Author: edd
Date: 2012-03-20 01:30:13 +0100 (Tue, 20 Mar 2012)
New Revision: 3532
Modified:
pkg/RcppSMC/R/simGaussian.R
pkg/RcppSMC/R/simLineart.R
pkg/RcppSMC/R/simNonlin.R
pkg/RcppSMC/man/blockpfGaussianOpt.Rd
pkg/RcppSMC/man/pfLineartBS.Rd
pkg/RcppSMC/man/pfNonlinBS.Rd
Log:
a few fixes for the sim* functions
standardized Author field in help pages
Modified: pkg/RcppSMC/R/simGaussian.R
===================================================================
--- pkg/RcppSMC/R/simGaussian.R 2012-03-19 11:58:15 UTC (rev 3531)
+++ pkg/RcppSMC/R/simGaussian.R 2012-03-20 00:30:13 UTC (rev 3532)
@@ -1,8 +1,8 @@
simGaussian <- function(len = 250)
{
- sim <- c();
- sim$state <- cumsum(rnorm(len));
- sim$data <- sim$state + rnorm(len);
+ sim <- c()
+ sim$state <- cumsum(rnorm(len))
+ sim$data <- sim$state + rnorm(len)
invisible(sim)
}
Modified: pkg/RcppSMC/R/simLineart.R
===================================================================
--- pkg/RcppSMC/R/simLineart.R 2012-03-19 11:58:15 UTC (rev 3531)
+++ pkg/RcppSMC/R/simLineart.R 2012-03-20 00:30:13 UTC (rev 3532)
@@ -1,17 +1,15 @@
simLineart <- function(len = 250)
{
- sim <- c();
-
- statex <- cumsum(rnorm(len));
- statey <- cumsum(rnorm(len));
+ sim <- c()
- datax <- statex + rt(len,df=4);
- datay <- statey + rt(len,df=4);
+ statex <- cumsum(rnorm(len))
+ statey <- cumsum(rnorm(len))
- sim$state <- c(statex,statey);
- dim(sim$state) <- c(2,2);
- sim$data <- c(datax,datay);
- dim(sim$data) <- c(2,2);
+ datax <- statex + rt(len,df=4)
+ datay <- statey + rt(len,df=4)
- invisible(sim);
+ sim$state <- matrix(cbind(statex,statey), ncol=2, dimnames=list(NULL, c("x", "y")))
+ sim$data <- matrix(cbind(datax,datay), ncol=2, dimnames=list(NULL, c("x", "y")))
+
+ invisible(sim)
}
Modified: pkg/RcppSMC/R/simNonlin.R
===================================================================
--- pkg/RcppSMC/R/simNonlin.R 2012-03-19 11:58:15 UTC (rev 3531)
+++ pkg/RcppSMC/R/simNonlin.R 2012-03-20 00:30:13 UTC (rev 3532)
@@ -1,14 +1,14 @@
simNonlin <- function(len = 50)
{
- sim <- c();
+ sim <- c()
- innovations <- rnorm(len) * sqrt(10);
- sim$state[1] = innovations[1];
- for (i in 2:len)
- sim$state[i] = 0.5 * sim$state[i-1] + 25 * sim$state[i-1] / (1 +
- sim$state[i-1]^2) + 8 * cos(1.2*(i-1)) + innovations[i];
- end
- sim$data <- sim$state^2 / 20 + rnorm(len);
+ innovations <- rnorm(len) * sqrt(10)
+ sim$state[1] <- innovations[1]
+ for (i in 2:len) {
+ sim$state[i] <- 0.5 * sim$state[i-1] + 25 * sim$state[i-1] /
+ (1 + sim$state[i-1]^2) + 8 * cos(1.2*(i-1)) + innovations[i]
+ }
+ sim$data <- sim$state^2 / 20 + rnorm(len)
invisible(sim)
}
Modified: pkg/RcppSMC/man/blockpfGaussianOpt.Rd
===================================================================
--- pkg/RcppSMC/man/blockpfGaussianOpt.Rd 2012-03-19 11:58:15 UTC (rev 3531)
+++ pkg/RcppSMC/man/blockpfGaussianOpt.Rd 2012-03-20 00:30:13 UTC (rev 3532)
@@ -40,8 +40,9 @@
which the state evolution and observation equations are:
x(n) = x(n-1) + e(n) and
y(n) = x(n) + f(n)
- where e(n) and f(n) are mutually-independent standard normal random variables. The 'optimal'
- block-sampling proposal described by (Doucet et al., 2006) is employed.
+ where e(n) and f(n) are mutually-independent standard normal random
+ variables. The 'optimal' block-sampling proposal described by Doucet
+ et al (2006) is employed.
The \code{simGaussian} function simulates from the same model returning both
the state and observation vectors.
@@ -55,5 +56,5 @@
sim <- simGaussian(len=250)
res <- blockpfGaussianOpt(sim$data,lag=5,plot=TRUE)
}
-\author{Adam M. Johansen}
+\author{Adam M. Johansen and Dirk Eddelbuettel}
\keyword{programming}
Modified: pkg/RcppSMC/man/pfLineartBS.Rd
===================================================================
--- pkg/RcppSMC/man/pfLineartBS.Rd 2012-03-19 11:58:15 UTC (rev 3531)
+++ pkg/RcppSMC/man/pfLineartBS.Rd 2012-03-20 00:30:13 UTC (rev 3532)
@@ -65,5 +65,5 @@
res <- pfLineartBS(plot=TRUE)
res <- pfLineartBS(onlinePlot=pfLineartBSOnlinePlot)
}
-\author{Adam M. Johansen for SMCTC, Dirk Eddelbuettel for the RcppSMC wrapper.}
+\author{Adam M. Johansen and Dirk Eddelbuettel}
\keyword{programming}
Modified: pkg/RcppSMC/man/pfNonlinBS.Rd
===================================================================
--- pkg/RcppSMC/man/pfNonlinBS.Rd 2012-03-19 11:58:15 UTC (rev 3531)
+++ pkg/RcppSMC/man/pfNonlinBS.Rd 2012-03-20 00:30:13 UTC (rev 3532)
@@ -50,5 +50,5 @@
sim <- simNonlin(len=50)
res <- pfNonlinBS(sim$data,particles=500,plot=TRUE)
}
-\author{Adam M. Johansen}
+\author{Adam M. Johansen and Dirk Eddelbuettel}
\keyword{programming}
More information about the Rcpp-commits
mailing list