Add test/README: shell file self-documented
[valse.git] / pkg / tests / testthat / helper-clustering.R
CommitLineData
5ce95f26
BA
1# Compute the sum of (normalized) sum of squares of closest distances to a medoid.
2computeDistortion <- function(series, medoids)
3{
4 n <- ncol(series)
5 L <- nrow(series)
6 distortion <- 0.
7 for (i in seq_len(n))
8 distortion <- distortion + min( colSums( sweep(medoids,1,series[,i],'-')^2 ) / L )
9
10 sqrt( distortion / n )
11}