movingAverage signal k1 k2 = 
    map y [0,1..(length signal - 1)]
    where 
          samplesPerMs = (length signal `div` samplingTime)
          nk1 = samplesPerMs * k1
          nk2 = samplesPerMs * k2

          y :: Int -> Double
          y n = let a = max 1 (n - nk1) 
                    b = min (length signal - 1) (n + nk2)
                in  fromIntegral (sum $ (take (b - a + 1)) $ 
                                         drop (a - 1) signal) /
                    fromIntegral (b - a + 1)
            

-- Rectangular Window function which takes the size of the 
-- window "win_sz" and "n", returns 1 if n is inside the window, 
-- 0 otherwise 
movingAverage signal k1 k2 = 
    map y [0,1..(length signal - 1)]
    where 
          samplesPerMs = (length signal `div` samplingTime)
          nk1 = samplesPerMs * k1
          nk2 = samplesPerMs * k2

          y :: Int -> Double
          y n = let a = max 1 (n - nk1) 
                    b = min (length signal - 1) (n + nk2)
                in  fromIntegral (sum $ (take (b - a + 1)) $ 
                                         drop (a - 1) signal) /
                    fromIntegral (b - a + 1)
            

-- Rectangular Window function which takes the size of the 
-- window "win_sz" and "n", returns 1 if n is inside the window, 
-- 0 otherwise 
movingAverage signal k1 k2 = 
    map y [0,1..(length signal - 1)]
    where 
          samplesPerMs = (length signal `div` samplingTime)
          nk1 = samplesPerMs * k1
          nk2 = samplesPerMs * k2

          y :: Int -> Double
          y n = let a = max 1 (n - nk1) 
                    b = min (length signal - 1) (n + nk2)
                in  fromIntegral (sum $ (take (b - a + 1)) $ 
                                         drop (a - 1) signal) /
                    fromIntegral (b - a + 1)
            

-- Rectangular Window function which takes the size of the 
-- window "win_sz" and "n", returns 1 if n is inside the window, 
-- 0 otherwise 