Created
June 14, 2018 12:23
-
-
Save cppxor2arr/1da5397c8eb26a6b5b5bb651f5ab5f18 to your computer and use it in GitHub Desktop.
mean normalization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
average :: Fractional a => [a] -> a | |
average xs = sum xs / fromIntegral (length xs) | |
range :: (Num a, Ord a) => [a] -> a | |
range xs = maximum xs - minimum xs | |
meanNormalize :: (Fractional a, Ord a) => [a] -> a -> a | |
meanNormalize xs = (/ range xs) . subtract (average xs) | |
-- GHCI | |
> l = [1..5] | |
> map (meanNormalize l) l | |
[-0.5,-0.25,0.0,0.25,0.5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment