Skip to content

Instantly share code, notes, and snippets.

@m1el
Last active December 28, 2015 07:59
Show Gist options
  • Save m1el/7468787 to your computer and use it in GitHub Desktop.
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
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