packages feed

hstatistics 0.2.2.2 → 0.2.2.4

raw patch · 8 files changed

+75/−28 lines, 8 filesdep ~hmatrix-gsl-stats

Dependency ranges changed: hmatrix-gsl-stats

Files

CHANGES view
@@ -54,4 +54,10 @@ 		improved ICA decorrelation step  0.2.2.2:-		+		reflected changes in hmatrix exports++0.2.2.3:+		reflected changes in hmatrix exports++0.2.2.4:+		added mean/variance for lists/vectors/matrices
LICENSE view
@@ -1,2 +1,10 @@-Copyright A.V.H. McPhail 2010-GPL license+Copyright (c) 2010, A.V.H. McPhail+All rights reserved.++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.+    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.+    * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
hstatistics.cabal view
@@ -1,6 +1,6 @@ Name:               hstatistics-Version:            0.2.2.2-License:            GPL+Version:            0.2.2.4+License:            BSD3 License-file:       LICENSE Copyright:          (c) A.V.H. McPhail 2010 Author:             Vivian McPhail@@ -12,7 +12,10 @@      Purely functional interface for statistics based on hmatrix and hmatrix-gsl-stats      .      When hmatrix is installed with -fvector, the vector type is Data.Vector.Storable-     from the vector package.+     from the vector package and compatible with the 'statistics' package +     <http://hackage.haskell.org/package/statistics +     .+     Feature requests, suggestions, and bug fixes welcome. Category:           Math, Statistics tested-with:        GHC ==6.12.1 @@ -27,7 +30,7 @@      Build-Depends:      base >= 3 && < 5,                         array, random,-                        hmatrix >= 0.10.0, hmatrix-gsl-stats >= 0.1.2.1+                        hmatrix >= 0.10.0, hmatrix-gsl-stats >= 0.1.2.4      Extensions:          @@ -50,5 +53,5 @@      source-repository head         type:     darcs-        location: http://code.haskell.org/hstatistics+        location: darcs get http://code.haskell.org/hstatistics 
lib/Numeric/Statistics.hs view
@@ -14,15 +14,18 @@ -----------------------------------------------------------------------------  module Numeric.Statistics (-                           Sample,Samples,-                          covarianceMatrix+                           Sample,Samples+                          , covarianceMatrix+                          , meanList, meanArray, meanMatrix+                          , varianceList, varianceArray, varianceMatrix                           ) where   ----------------------------------------------------------------------------- -import Data.Packed.Vector-import Data.Packed.Matrix+import Numeric.Vector+import Numeric.Matrix+--import Numeric.Container  import qualified Data.Array.IArray as I  @@ -40,5 +43,40 @@                  -> Matrix Double               -- ^ the symmetric covariance matrix covarianceMatrix d = let (s,f) = I.bounds d                       in fromArray2D $ I.array ((s,s),(f,f)) $ concat $ map (\(x,y) -> let c = covariance (d I.! x) (d I.! y) in if x == y then [((x,y),c)] else [((x,y),c),((y,x),c)]) $ filter (\(x,y) -> x <= y) $ I.range ((s,s),(f,f))++-----------------------------------------------------------------------------++-- | the mean of a list of vectors+meanList :: (Container Vector a, Num (Vector a)) => [Sample a] -> Sample a+meanList []     = error "meanVectors: empty list"+meanList [s]    = s+meanList (s:ss) = let ln = fromIntegral $ length ss + 1+                  in scale (recip ln) $ foldl (+) s ss++-- | the mean of an array of vectors+meanArray :: (Container Vector a, Num (Vector a)) => Samples a -> Sample a+meanArray a = meanList $ I.elems a++-- | the mean of a matrix with data series in rows+meanMatrix :: (Container Vector a, Num (Vector a), Element a) => Matrix a -> Sample a+meanMatrix a = meanList $ toRows a++-----------------------------------------------------------------------------++-- | the variance of a list of vectors+varianceList :: (Container Vector a, Floating (Vector a)) => [Sample a] -> Sample a+varianceList []  = error "varianceList: empty list"+varianceList [s] = constant 0 (dim s)+varianceList l   = let mxs = meanList (map (** 2) l)+                       msx = (meanList l) ** 2+                   in mxs - msx++-- | the variance of an array of vectors+varianceArray :: (Container Vector a, Floating (Vector a)) => Samples a -> Sample a+varianceArray a = varianceList $ I.elems a++-- | the variance of a matrix with data series in rows+varianceMatrix :: (Container Vector a, Floating (Vector a), Element a) => Matrix a -> Sample a+varianceMatrix a = varianceList $ toRows a  -----------------------------------------------------------------------------
lib/Numeric/Statistics/ICA.hs view
@@ -32,13 +32,10 @@  import qualified Data.Array.IArray as I  -import Data.Packed.Vector-import Data.Packed.Matrix---import Data.Packed.Random+import Numeric.Vector+import Numeric.Matrix -import Numeric.LinearAlgebra.Interface import Numeric.LinearAlgebra.Algorithms-import Numeric.LinearAlgebra.Linear  import Numeric.GSL.Statistics 
lib/Numeric/Statistics/Information.hs view
@@ -21,13 +21,11 @@  ----------------------------------------------------------------------------- -import Data.Packed.Vector+import Numeric.Vector  import Numeric.Statistics.PDF  import Numeric.LinearAlgebra.Algorithms()-import Numeric.LinearAlgebra.Interface()-import Numeric.LinearAlgebra.Linear  ----------------------------------------------------------------------------- @@ -55,7 +53,7 @@                    -> a                                          -- ^ the second dimension distribution                    -> (Vector Double, Vector Double)             -- ^ the sequence                    -> Double         -- ^ the mutual information-mutual_information p px py (x,y) = let ps = probability p $ zipVector (,) x y+mutual_information p px py (x,y) = let ps = probability p $ zipVector x y                                        xs = probability px x                                        ys = probability py y                                    in negate $ dot ps (logE ps - logE (xs*ys)) 
lib/Numeric/Statistics/PCA.hs view
@@ -22,12 +22,9 @@  import qualified Data.Array.IArray as I  -import Data.Packed.Vector-import Data.Packed.Matrix--import Numeric.LinearAlgebra.Interface+import Numeric.Vector+import Numeric.Matrix import Numeric.LinearAlgebra.Algorithms-import Numeric.LinearAlgebra.Linear  import Numeric.GSL.Statistics 
lib/Numeric/Statistics/PDF.hs view
@@ -9,7 +9,7 @@ -- Stability   :  provisional -- Portability :  portable ----- Probability Density Function interface+-- Probability Distribution Function interface -- ----------------------------------------------------------------------------- @@ -34,7 +34,7 @@  ----------------------------------------------------------------------------- --- ^ a probability density function+-- ^ a probability distribution function data PDFFunction a = P_Func (a -> Double)     -- p(x)  -----------------------------------------------------------------------------