S. Doaitse Swierstra schrieb:
Avoiding repeated additions:
movingAverage :: Int - [Float] - [Float]
movingAverage n l = runSums (sum . take n $l) l (drop n l)
where n' = fromIntegral n
runSums sum (h:hs) (t:ts) = sum / n' : runSums (sum-h+t) hs ts
runSums _
On 29 sep 2010, at 00:58, o...@cs.otago.ac.nz wrote:
Avoiding repeated additions:
movingAverage :: Int - [Float] - [Float]
movingAverage n l = runSums (sum . take n $l) l (drop n l)
where n' = fromIntegral n
runSums sum (h:hs) (t:ts) = sum / n' : runSums (sum-h+t) hs ts
Avoiding repeated additions:
movingAverage :: Int - [Float] - [Float]
movingAverage n l = runSums (sum . take n $l) l (drop n l)
where n' = fromIntegral n
runSums sum (h:hs) (t:ts) = sum / n' : runSums (sum-h+t) hs ts
runSums _ _ [] = []
Doaitse
On 28
On 27/09/2010, at 5:20 AM, rgowka1 wrote:
Type signature would be Int - [Double] - [(Double,Double)]
Any thoughts or ideas on how to calculate a n-element moving average
of a list of Doubles?
Let's say [1..10]::[Double]
what is the function to calculate the average of the 3 elements?
Type signature would be Int - [Double] - [(Double,Double)]
Any thoughts or ideas on how to calculate a n-element moving average
of a list of Doubles?
Let's say [1..10]::[Double]
what is the function to calculate the average of the 3 elements?
[(1,0),(2,0),(3,2),(4,3)] :: [(Double,Double)]
2010/9/26 rgowka1 rgow...@gmail.com:
Type signature would be Int - [Double] - [(Double,Double)]
Any thoughts or ideas on how to calculate a n-element moving average
of a list of Doubles?
Let's say [1..10]::[Double]
what is the function to calculate the average of the 3 elements?