{-# LANGUAGE FlexibleContexts #-}
module Statistics.Sample.Internal
(
robustSumVar
, sum
) where
import Numeric.Sum (kbn, sumVector)
import Prelude hiding (sum)
import Statistics.Function (square)
import qualified Data.Vector.Generic as G
robustSumVar :: (G.Vector v Double) => Double -> v Double -> Double
robustSumVar :: forall (v :: * -> *).
Vector v Double =>
Double -> v Double -> Double
robustSumVar Double
m = forall (v :: * -> *). Vector v Double => v Double -> Double
sum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (v :: * -> *) a b.
(Vector v a, Vector v b) =>
(a -> b) -> v a -> v b
G.map (Double -> Double
square forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => a -> a -> a
subtract Double
m)
{-# INLINE robustSumVar #-}
sum :: (G.Vector v Double) => v Double -> Double
sum :: forall (v :: * -> *). Vector v Double => v Double -> Double
sum = forall (v :: * -> *) s.
(Vector v Double, Summation s) =>
(s -> Double) -> v Double -> Double
sumVector KBNSum -> Double
kbn
{-# INLINE sum #-}