1 #shorthand: map 1->1, 2->2, 3->3, 4->1, ..., 149->2, 150->3, ... (is base==3)
5 # NOTE: medoids can be a big.matrix
6 computeDistortion = function(series, medoids)
8 n = nrow(series) ; L = ncol(series)
10 if (bigmemory::is.big.matrix(medoids))
13 distortion = distortion + min( colSums( sweep(medoids,1,series[,i],'-')^2 ) / L )