| 1 | Ref_Centroids <<- NULL |
| 2 | Tot_Nb_Curves <<- NA |
| 3 | |
| 4 | #' initCentroids |
| 5 | #' |
| 6 | #' Must be called before getDetRandCurve() |
| 7 | #' |
| 8 | #' @param N Number of curves |
| 9 | #' @param D Number of sample points |
| 10 | #' @param K Number of clusters |
| 11 | #' |
| 12 | #' @export |
| 13 | initClustersParams <- function(N, D, K) |
| 14 | { |
| 15 | # Generate K centroids |
| 16 | Ref_Centroids <<- sapply(1:K, function(k) cumsum(rnorm(D))) |
| 17 | Tot_Nb_Curves <<- N |
| 18 | } |
| 19 | |
| 20 | #' getDetRandCurve |
| 21 | #' |
| 22 | #' TODO: improve this (using known clusters centers...) |
| 23 | #' |
| 24 | #' @param i Some index |
| 25 | #' |
| 26 | #' @examples |
| 27 | #' \dontrun{ |
| 28 | #' initCentroids(N=250000, D=15000, K=15) |
| 29 | #' res_ascii <- claws(getDetRandCurve, K1=50, K2=15, nb_series_per_chunk=500, |
| 30 | #' nb_items_clust=100, random=FALSE, verbose=TRUE, ncores_clust=3) |
| 31 | #' } |
| 32 | #' @export |
| 33 | getDetRandCurve <- function(indices) |
| 34 | { |
| 35 | sapply(indices, function(i) { |
| 36 | if (i > Tot_Nb_Curves) |
| 37 | return (NULL) |
| 38 | set.seed(i) |
| 39 | j <- sample(ncol(Ref_Centroids), 1) |
| 40 | Ref_Centroids[,j] + rnorm(nrow(Ref_Centroids)) |
| 41 | }) |
| 42 | } |