I need to calculate a moving average and stddev for 20 fields. I came up with the following windowed query (see example) .
val w = Window.partitionBy("id").orderBy("cykle").rowsBetween(0, windowRange)
val x = withrul.select('*,
mean($"s1").over(w).as("a1"),
sqrt( sum(pow($"s1" - mean($"s1").over(w),2)).over(w) / 5).as("sd1"),
... repeat 19 times more
Is there a way of doing this with a single vector column (feature vector) ?