X-Git-Url: https://git.auder.net/?p=epclust.git;a=blobdiff_plain;f=epclust%2FR%2Futils.R;h=708367482bbd093ff18166d29d5df1968bdfb77b;hp=e0f25ece5f4ba50a3d9845f7f1f13763b0e10457;hb=0e2dce80a3fddaca50c96c6c27a8b32468095d6c;hpb=48108c3999d28d973443fa5e78f73a0a9f2bfc07 diff --git a/epclust/R/utils.R b/epclust/R/utils.R index e0f25ec..7083674 100644 --- a/epclust/R/utils.R +++ b/epclust/R/utils.R @@ -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) ) ) ) ) + }) +}