moving-average

Apache Spark Moving Average

☆樱花仙子☆ 提交于 2019-11-26 04:09:55
问题 I have a huge file in HDFS having Time Series data points (Yahoo Stock prices). I want to find the moving average of the Time Series how do I go about writing the Apache Spark job to do that . 回答1: You can use the sliding function from MLLIB which probably does the same thing as Daniel's answer. You will have to sort the data by time before using the sliding function. import org.apache.spark.mllib.rdd.RDDFunctions._ sc.parallelize(1 to 100, 10) .sliding(3) .map(curSlice => (curSlice.sum /

Calculating moving average

[亡魂溺海] 提交于 2019-11-25 22:29:30
问题 I\'m trying to use R to calculate the moving average over a series of values in a matrix. The normal R mailing list search hasn\'t been very helpful though. There doesn\'t seem to be a built-in function in R will allow me to calculate moving averages. Do any packages provide one? Or do I need to write my own? 回答1: Rolling Means/Maximums/Medians in the zoo package (rollmean) MovingAverages in TTR ma in forecast 回答2: Or you can simply calculate it using filter, here's the function I use: ma <-