Description Usage Arguments Value Author(s) Examples
Rescales channel vectors to get the same average.
1 2 | ## S3 method for class 'list'
normalizeDifferencesToAverage(x, baseline=1, FUN=median, ...)
|
x |
A |
baseline |
An |
FUN |
A |
... |
Additional arguments passed to the |
Returns a normalized list
of length K.
Henrik Bengtsson
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Simulate three shifted tracks of different lengths with same profiles
ns <- c(A=2, B=1, C=0.25)*1000;
xx <- lapply(ns, FUN=function(n) { seq(from=1, to=max(ns), length.out=n) });
zz <- mapply(seq(along=ns), ns, FUN=function(z,n) rep(z,n));
yy <- list(
A = rnorm(ns["A"], mean=0, sd=0.5),
B = rnorm(ns["B"], mean=5, sd=0.4),
C = rnorm(ns["C"], mean=-5, sd=1.1)
);
yy <- lapply(yy, FUN=function(y) {
n <- length(y);
y[1:(n/2)] <- y[1:(n/2)] + 2;
y[1:(n/4)] <- y[1:(n/4)] - 4;
y;
});
# Shift all tracks toward the first track
yyN <- normalizeDifferencesToAverage(yy, baseline=1);
# The baseline channel is not changed
stopifnot(identical(yy[[1]], yyN[[1]]));
# Get the estimated parameters
fit <- attr(yyN, "fit");
# Plot the tracks
layout(matrix(1:2, ncol=1));
x <- unlist(xx);
col <- unlist(zz);
y <- unlist(yy);
yN <- unlist(yyN);
plot(x, y, col=col, ylim=c(-10,10));
plot(x, yN, col=col, ylim=c(-10,10));
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.