-- EPS formulas for mean and variance calculations mean :: [Float] -> Float mean [] = 0 mean x = sum x / fromIntegral (length x) s :: [Float] -> Float s [] = 0 s x = sqrt ((sum (map (\xs -> (xs - (mean x)) ** 2) x)) / (fromIntegral ((length x) - 1))) -- recursive versions s_recursive :: [Float] -> Float s_recursive [] = 0 s_recursive x = sqrt ((aux x (mean x)) / (fromIntegral ((length x) - 1))) where aux [] _ = 0 aux (x : xs) y = ((x - y) ** 2) + aux xs y mean_recursive :: [Float] -> Float mean_recursive [] = 0 mean_recursive x = aux x / fromIntegral (length x) where aux [] = 0 aux (x : xs) = x + aux xs
Comments
0 B
|0 👍
/0 👎
0 B
|👍
/👎