Description Usage Arguments Value Author(s) Examples
View source: R/Parallel_PELTSM2.R
Splits the data into chunks by sending the first point to the first core, the second point to the second core etc, and runs parallel changepoint detection on each chunk then merges the results and runs parallel detection using the detected changepoints in step 1 as the candidate changepoint locations.
1 2 | Parallel_PELTSM2(data, penalty, pruning, sum.stat = norm.sum, cost, minseglen,
ncores)
|
data |
A vector of data-points within which you with to find changepoints. |
penalty |
The value of the penalty. |
pruning |
If true PELT is used, if false Optimal Partitioning is used. |
sum.stat |
This can be “norm.sum" or “exp.sum". |
cost |
This can be “norm.mean.cost", “norm.var.cost", “norm.meanvar.cost" or “exp.cost". |
ncores |
Number of cores to use. |
The detected changepoints.
Kaylea Haynes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ### Set up parallel environment ###
library(doParallel)
library(foreach)
ncores <- c(10)
cl <- makeCluster(ncores)
registerDoParallel(cl)
### Generate some data from the blocks data set ####
cpts <- round(c(0,0.1, 0.13, 0.15, 0.23, 0.25, 0.40, 0.44, 0.65, 0.76, 0.78, 0.81,1)*10000)
segment_param <- c(0, 4, -1, 2, -2, 3, -1.2, 0.9, 5.2, 2.1, 4.2, 0)
data <- NULL
for (i in 1:(length(cpts)-1)){
data_new <- rep(segment_param[i],cpts[i+1] - cpts[i])
data <- c(data, data_new)
}
data <- data + rnorm(10000,0,1)
Parallel_PELTSM2(data, 2*log(length(data)), TRUE, sum.stat = norm.sum, cost = norm.mean.cost, minseglen =1, ncores=10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.