-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple linear and quadratic regression -- -- A simple package with a module for -- -- -- -- All specialized to Double. @package regression-simple @version 0.1 module Math.Regression.Simple -- | Linear regression. -- -- The type is -- --
--   linear :: [(Double, Double)] -> V2
--   
-- -- but overloaded to work with boxed and unboxed Vectors. -- --
--   >>> let input1 = [(0, 1), (1, 3), (2, 5)]
--   
--   >>> linear input1
--   V2 2.0 1.0
--   
-- --
--   >>> let input2 = [(0.1, 1.2), (1.3, 3.1), (1.9, 4.9), (3.0, 7.1), (4.1, 9.0)]
--   
--   >>> linear input2
--   V2 2.0063237774030345 0.8868465430016883
--   
linear :: (Foldable' xs x, IsDoublePair x) => xs -> V2 -- | Quadratic regression. -- -- The type is -- --
--   quadratic :: [(Double, Double)] -> V3
--   
-- -- but overloaded to work with boxed and unboxed Vectors. -- --
--   >>> let input1 = [(0, 1), (1, 3), (2, 5)]
--   
--   >>> quadratic input1
--   V3 0.0 2.0 1.0
--   
-- --
--   >>> let input2 = [(0.1, 1.2), (1.3, 3.1), (1.9, 4.9), (3.0, 7.1), (4.1, 9.0)]
--   
--   >>> quadratic input2
--   V3 (-5.886346291028133e-3) 2.0312938469708826 0.8715454176158062
--   
-- --
--   >>> let input3 = [(0, 2), (1, 3), (2, 6), (3, 11)]
--   
--   >>> quadratic input3
--   V3 1.0 0.0 1.999999999999993
--   
quadratic :: (Foldable' xs x, IsDoublePair x) => xs -> V3 -- | Do both linear and quadratic regression in one data scan. -- --
--   >>> let input2 = [(0.1, 1.2), (1.3, 3.1), (1.9, 4.9), (3.0, 7.1), (4.1, 9.0)]
--   
--   >>> quadraticAndLinear input2
--   (V3 (-5.886346291028133e-3) 2.0312938469708826 0.8715454176158062,V2 2.0063237774030345 0.8868465430016883)
--   
quadraticAndLinear :: (Foldable' xs x, IsDoublePair x) => xs -> (V3, V2) -- | Addition class Add a zero :: Add a => a add :: Add a => a -> a -> a infixl 6 `add` -- | Identity class Eye a eye :: Eye a => a -- | Multiplication of different things. class Eye a => Mult a b c | a b -> c mult :: Mult a b c => a -> b -> c infixl 7 `mult` -- | Determinant class Eye a => Det a det :: Det a => a -> Double -- | Inverse class Det a => Inv a inv :: Inv a => a -> a -- | Solve linear equation. -- --
--   >>> zerosLin (V2 1 2)
--   -2.0
--   
zerosLin :: V2 -> Double -- | Solve quadratic equation. -- --
--   >>> zerosQuad (V3 2 0 (-1))
--   Right (-0.7071067811865476,0.7071067811865476)
--   
-- --
--   >>> zerosQuad (V3 2 0 1)
--   Left ((-0.0) :+ (-0.7071067811865476),(-0.0) :+ 0.7071067811865476)
--   
-- -- Double root is not treated separately: -- --
--   >>> zerosQuad (V3 1 0 0)
--   Right (-0.0,0.0)
--   
-- --
--   >>> zerosQuad (V3 1 (-2) 1)
--   Right (1.0,1.0)
--   
zerosQuad :: V3 -> Either (Complex Double, Complex Double) (Double, Double) -- | Find an optima point. -- --
--   >>> optimaQuad (V3 1 (-2) 0)
--   1.0
--   
-- -- compare to -- --
--   >>> zerosQuad (V3 1 (-2) 0)
--   Right (0.0,2.0)
--   
optimaQuad :: V3 -> Double -- | 2d vector. Strict pair of Doubles. -- -- Also used to represent linear polynomial: V2 a b -- <math>. data V2 V2 :: !Double -> !Double -> V2 -- | 2×2 matrix. data M22 M22 :: !Double -> !Double -> !Double -> !Double -> M22 -- | 3d vector. Strict triple of Doubles. -- -- Also used to represent quadratic polynomial: V3 a b c -- <math>. data V3 V3 :: !Double -> !Double -> !Double -> V3 -- | 3×3 matrix. data M33 M33 :: !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> M33 -- | Like Foldable but with element in the class definition. class Foldable' xs x | xs -> x foldl' :: Foldable' xs x => (b -> x -> b) -> b -> xs -> b -- | Class witnessing that dp has a pair of Doubles. class IsDoublePair dp withDP :: IsDoublePair dp => dp -> (Double -> Double -> r) -> r makeDP :: IsDoublePair dp => Double -> Double -> dp instance GHC.Show.Show Math.Regression.Simple.M33 instance GHC.Classes.Eq Math.Regression.Simple.M33 instance GHC.Show.Show Math.Regression.Simple.V3 instance GHC.Classes.Eq Math.Regression.Simple.V3 instance GHC.Show.Show Math.Regression.Simple.M22 instance GHC.Classes.Eq Math.Regression.Simple.M22 instance GHC.Show.Show Math.Regression.Simple.V2 instance GHC.Classes.Eq Math.Regression.Simple.V2 instance Math.Regression.Simple.IsDoublePair Math.Regression.Simple.V2 instance (a Data.Type.Equality.~ GHC.Types.Double, b Data.Type.Equality.~ GHC.Types.Double) => Math.Regression.Simple.IsDoublePair (a, b) instance Math.Regression.Simple.Foldable' [a] a instance Math.Regression.Simple.Foldable' (Data.Vector.Vector a) a instance Data.Vector.Unboxed.Base.Unbox a => Math.Regression.Simple.Foldable' (Data.Vector.Unboxed.Base.Vector a) a instance Math.Regression.Simple.Add Math.Regression.Simple.M33 instance Math.Regression.Simple.Eye Math.Regression.Simple.M33 instance Math.Regression.Simple.Det Math.Regression.Simple.M33 instance Math.Regression.Simple.Inv Math.Regression.Simple.M33 instance Math.Regression.Simple.Mult GHC.Types.Double Math.Regression.Simple.M33 Math.Regression.Simple.M33 instance Math.Regression.Simple.Mult Math.Regression.Simple.M33 Math.Regression.Simple.V3 Math.Regression.Simple.V3 instance Math.Regression.Simple.Add Math.Regression.Simple.V3 instance Math.Regression.Simple.Mult GHC.Types.Double Math.Regression.Simple.V3 Math.Regression.Simple.V3 instance Math.Regression.Simple.Add Math.Regression.Simple.M22 instance Math.Regression.Simple.Eye Math.Regression.Simple.M22 instance Math.Regression.Simple.Det Math.Regression.Simple.M22 instance Math.Regression.Simple.Inv Math.Regression.Simple.M22 instance Math.Regression.Simple.Mult GHC.Types.Double Math.Regression.Simple.M22 Math.Regression.Simple.M22 instance Math.Regression.Simple.Mult Math.Regression.Simple.M22 Math.Regression.Simple.V2 Math.Regression.Simple.V2 instance Math.Regression.Simple.Mult Math.Regression.Simple.M22 Math.Regression.Simple.M22 Math.Regression.Simple.M22 instance Math.Regression.Simple.Add Math.Regression.Simple.V2 instance Math.Regression.Simple.Mult GHC.Types.Double Math.Regression.Simple.V2 Math.Regression.Simple.V2 instance Math.Regression.Simple.Inv GHC.Types.Double instance Math.Regression.Simple.Det GHC.Types.Double instance Math.Regression.Simple.Eye GHC.Types.Double instance Math.Regression.Simple.Add GHC.Types.Double