- #... return wavelets coeffs : compute in parallel !
- #TODO: always keep ID in first column
-}
-
-coeffsToCurves = function(coeffs)
-{
- #re-expand on wavelet basis
+ library(wavelets)
+ L = length(series[1,])
+ D = ceiling( log(L-1) )
+ nb_sample_points = 2^D
+ #TODO: parallel::parApply() ?!
+ res = apply(series, 1, function(x) {
+ interpolated_curve = spline(1:(L-1), x[2:L], n=nb_sample_points)$y
+ W = wavelets::dwt(interpolated_curve, filter=wf, D)@W
+ nrj_coeffs = rev( sapply( W, function(v) ( sqrt( sum(v^2) ) ) ) )
+ return ( c(x[1], nrj_coeffs) )
+ })
+ return (as.data.frame(res))