#' Generate a set of features on two sets of simulations
#'
#' Simulations are generated by sim_suite() and the
#' features in the features argument are computed.a
#' A dataframe of features, feature name and id are returned.
#'
#' @param n Number of functions for each group
#' @param len Length of simulations
#' @param features Features to compute
#' @param seed Random generator seed.
#'
#' @return A dataframe of features, id and function names
make_sim_features <- function(n, len, features, seed = 1) {
#----------------------------------------------------------
gs <- tssims::sim_suite()
fnames <- tssims::sim_names()
names(gs$group1)
set.seed(seed)
for(k in 1:length(gs$group1)){
f1 <- gs$group1[[k]]
f2 <- gs$group2[[k]]
ts_mat1 <- replicate(n, tssims::gen(tssims::jitter_params(f1))(len)) %>%
apply(., 2, ecomplex::normalize)
ts_mat2 <- replicate(n, tssims::gen(tssims::jitter_params(f2))(len)) %>%
apply(., 2, ecomplex::normalize)
df1 <- get_features(ts_mat1, features, id = "1", ncores = 4)
df2 <- get_features(ts_mat2, features, id = "2", ncores = 4)
temp <-rbind(df1, df2)
temp$fnames <- rep(fnames[k], n)
if(k == 1){
comb <- temp
} else {
comb <- rbind(comb, temp)
}
}
combn <- data.frame(apply(subset(comb, select = c(-id, -fnames)), 2, ecomplex::normalize))
combn$id <- as.factor(comb$id)
combn$fnames <- comb$fnames
combn
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.