module Network.Mux.DeltaQ.TraceStatsSupport where
import Network.Mux.DeltaQ.TraceTypes
import qualified Data.Vector.Unboxed as V
import Statistics.LinearRegression
estimateGS :: [(Int, SISec)] -> (Double, Double, Double)
estimateGS :: [(Int, SISec)] -> (Double, Double, Double)
estimateGS [(Int, SISec)]
xys
= let ([Int]
xs', [SISec]
ys') = forall a b. [(a, b)] -> ([a], [b])
unzip [(Int, SISec)]
xys
xs :: Vector Double
xs = forall a. Unbox a => [a] -> Vector a
V.fromList forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fromIntegral [Int]
xs'
ys :: Vector Double
ys = forall a. Unbox a => [a] -> Vector a
V.fromList forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (\(S Float
x) -> forall a. Fractional a => Rational -> a
fromRational forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Real a => a -> Rational
toRational forall a b. (a -> b) -> a -> b
$ Float
x) [SISec]
ys'
in forall (v :: * -> *).
Vector v Double =>
v Double -> v Double -> (Double, Double, Double)
linearRegressionRSqr Vector Double
xs Vector Double
ys