with parallel::export
[epclust.git] / epclust / R / utils.R
index e0f25ec..7083674 100644 (file)
@@ -31,3 +31,15 @@ getSeries(data, rank=NULL, id=NULL)
 {
        #TODO:
 }
+
+curvesToCoeffs = function(series, wf)
+{
+       L = length(series[1,])
+       D = ceiling( log2(L) )
+       nb_sample_points = 2^D
+       apply(series, 1, function(x) {
+               interpolated_curve = spline(1:L, x, n=nb_sample_points)$y
+               W = wavelets::dwt(interpolated_curve, filter=wf, D)@W
+               rev( sapply( W, function(v) ( sqrt( sum(v^2) ) ) ) )
+       })
+}