Last active
December 28, 2015 07:59
-
-
Save m1el/7468787 to your computer and use it in GitHub Desktop.
sigma rejection algorithm - returns average of values that are not too far from average
This file contains 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
import Data.List | |
sigmaRejection = sigmaRejection' 3 | |
sigmaRejection' distance xs = | |
mean $ filter (\x-> abs(mean xs - x) < distance * sigma) xs | |
where | |
mean xs = realToFrac (sum xs) / (genericLength xs) | |
sigma = sqrt $ ((sum xs)^2 - (sum $ map (^2) xs)) / genericLength xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment