1 # Shorthand: map 1->1, 2->2, 3->3, 4->1, ..., 149->2, 150->3, ... (is base==3)
5 # Compute the sum of (normalized) sum of squares of closest distances to a medoid.
6 # Note: medoids can be a big.matrix
7 computeDistortion = function(series, medoids)
9 if (bigmemory::is.big.matrix(medoids))
10 medoids = medoids[,] #extract standard matrix
12 n = ncol(series) ; L = nrow(series)
15 distortion = distortion + min( colSums( sweep(medoids,1,series[,i],'-')^2 ) / L )
17 sqrt( distortion / n )