- series = getSeries(indices)
- #...........
- #sapply(seq_along(inds), colMeans(getSeries(inds[[i]]$indices,inds[[i]]$ids)))
+ medoids = getSeries(indices)
+ K = nrow(medoids)
+ synchrones = matrix(0, nrow=K, ncol=ncol(medoids))
+ counts = rep(0,K)
+ index = 1
+ repeat
+ {
+ series = getSeriesForSynchrones((index-1)+seq_len(nb_series_per_chunk))
+ if (is.null(series))
+ break
+ #get medoids indices for this chunk of series
+ index = which.min( rowSums( sweep(medoids, 2, series[i,], '-')^2 ) )
+ synchrones[index,] = synchrones[index,] + series[i,]
+ counts[index] = counts[index] + 1
+ }
+ #NOTE: odds for some clusters to be empty? (when series already come from stage 2)
+ synchrones = sweep(synchrones, 1, counts, '/')