hstats 0.1 → 0.2
raw patch · 25 files changed
+31/−395 lines, 25 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Math.Statistics: covm :: (Floating a) => [[a]] -> [[a]]
- Math.Statistics: kurtosis :: (Floating b) => [b] -> b
- Math.Statistics: skew :: (Floating a) => [a] -> a
- Math.Statistics: var :: (Floating a) => [a] -> a
+ Math.Statistics: covMatrix :: (Floating a) => [[a]] -> [[a]]
Files
- _darcs/inventory +0/−2
- _darcs/patches/20070918213154-0e28a-c3676cccf964045a487682ba14406a05656b4001.gz binary
- _darcs/patches/pending +0/−2
- _darcs/prefs/author +0/−1
- _darcs/prefs/binaries +0/−59
- _darcs/prefs/boring +0/−49
- _darcs/prefs/motd +0/−0
- _darcs/pristine/LICENSE +0/−24
- _darcs/pristine/Setup.hs +0/−2
- _darcs/pristine/dist/build/autogen/Paths_hstats.hs +0/−26
- _darcs/pristine/dist/installed-pkg-config +0/−29
- _darcs/pristine/dist/setup-config +0/−1
- _darcs/pristine/hstats.cabal +0/−15
- _darcs/pristine/src/Math/Statistics.hs +0/−108
- dist/build/HShstats-0.1.o binary
- dist/build/Math/Statistics.hi binary
- dist/build/Math/Statistics.o binary
- dist/build/Math/Stats.hi binary
- dist/build/Math/Stats.o binary
- dist/build/autogen/Paths_hstats.hs +0/−26
- dist/build/libHShstats-0.1.a binary
- dist/installed-pkg-config +0/−29
- dist/setup-config +0/−1
- hstats.cabal +1/−1
- src/Math/Statistics.hs +30/−20
− _darcs/inventory
@@ -1,2 +0,0 @@-[initial commit.-mbeddoe@sftank.net**20070918213154]
− _darcs/patches/20070918213154-0e28a-c3676cccf964045a487682ba14406a05656b4001.gz
binary file changed (4199 → absent bytes)
− _darcs/patches/pending
@@ -1,2 +0,0 @@-{-}
− _darcs/prefs/author
@@ -1,1 +0,0 @@-mbeddoe@sftank.net
− _darcs/prefs/binaries
@@ -1,59 +0,0 @@-# Binary file regexps:-\.png$-\.PNG$-\.gz$-\.GZ$-\.pdf$-\.PDF$-\.jpg$-\.JPG$-\.jpeg$-\.JPEG$-\.gif$-\.GIF$-\.tif$-\.TIF$-\.tiff$-\.TIFF$-\.pnm$-\.PNM$-\.pbm$-\.PBM$-\.pgm$-\.PGM$-\.ppm$-\.PPM$-\.bmp$-\.BMP$-\.mng$-\.MNG$-\.tar$-\.TAR$-\.bz2$-\.BZ2$-\.z$-\.Z$-\.zip$-\.ZIP$-\.jar$-\.JAR$-\.so$-\.SO$-\.a$-\.A$-\.tgz$-\.TGZ$-\.mpg$-\.MPG$-\.mpeg$-\.MPEG$-\.iso$-\.ISO$-\.exe$-\.EXE$-\.doc$-\.DOC$-\.elc$-\.ELC$-\.pyc$-\.PYC$
− _darcs/prefs/boring
@@ -1,49 +0,0 @@-# Boring file regexps:-\.hi$-\.hi-boot$-\.o-boot$-\.o$-\.o\.cmd$-# *.ko files aren't boring by default because they might-# be Korean translations rather than kernel modules.-# \.ko$-\.ko\.cmd$-\.mod\.c$-(^|/)\.tmp_versions($|/)-(^|/)CVS($|/)-\.cvsignore$-^\.#-(^|/)RCS($|/)-,v$-(^|/)\.svn($|/)-\.bzr$-(^|/)SCCS($|/)-~$-(^|/)_darcs($|/)-\.bak$-\.BAK$-\.orig$-\.rej$-(^|/)vssver\.scc$-\.swp$-(^|/)MT($|/)-(^|/)\{arch\}($|/)-(^|/).arch-ids($|/)-(^|/),-\.prof$-(^|/)\.DS_Store$-(^|/)BitKeeper($|/)-(^|/)ChangeSet($|/)-\.py[co]$-\.elc$-\.class$-\#-(^|/)Thumbs\.db$-(^|/)autom4te\.cache($|/)-(^|/)config\.(log|status)$-^\.depend$-(^|/)(tags|TAGS)$-#(^|/)\.[^/]-(^|/|\.)core$-\.(obj|a|exe|so|lo|la)$-^\.darcs-temp-mail$
− _darcs/prefs/motd
− _darcs/pristine/LICENSE
@@ -1,24 +0,0 @@-* Copyright (c) 2007, SFTank-* 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 SFTank 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 REGENTS 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 REGENTS AND 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.
− _darcs/pristine/Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
− _darcs/pristine/dist/build/autogen/Paths_hstats.hs
@@ -1,26 +0,0 @@-module Paths_hstats (- version,- getBinDir, getLibDir, getDataDir, getLibexecDir,- getDataFileName- ) where--import Data.Version--version :: Version-version = Version {versionBranch = [0,1], versionTags = []}--bindir, libdir, datadir, libexecdir :: FilePath--bindir = "/usr/local/bin"-libdir = "/usr/local/lib/hstats-0.1/ghc-6.6"-datadir = "/usr/local/share/hstats-0.1"-libexecdir = "/usr/local/libexec"--getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath-getBinDir = return bindir-getLibDir = return libdir-getDataDir = return datadir-getLibexecDir = return libexecdir--getDataFileName :: FilePath -> IO FilePath-getDataFileName name = return (datadir ++ "/" ++ name)
− _darcs/pristine/dist/installed-pkg-config
@@ -1,29 +0,0 @@-name: hstats-version: 0.1-license: BSD3-copyright: Copyright (c) 2007, SFTank-maintainer: mbeddoe@<nospam>sftank.net-stability:-homepage: http://www.sftank.net-package-url:-description: A library of commonly used statistical functions-category: Math-author: Marshall Beddoe-exposed: True-exposed-modules: Math.Statistics-hidden-modules:-import-dirs: /usr/local/lib/hstats-0.1/ghc-6.6-library-dirs: /usr/local/lib/hstats-0.1/ghc-6.6-hs-libraries: HShstats-0.1-extra-libraries:-extra-ghci-libraries:-include-dirs:-includes:-depends: base-2.0 haskell98-1.0-hugs-options:-cc-options:-ld-options:-framework-dirs:-frameworks:-haddock-interfaces: /usr/local/share/doc/hstats-0.1/html/hstats/hstats.haddock-haddock-html: /usr/local/share/doc/hstats-0.1/html/hstats
− _darcs/pristine/dist/setup-config
@@ -1,1 +0,0 @@-LocalBuildInfo {installDirTemplates = InstallDirTemplates {prefixDirTemplate = "/usr/local", binDirTemplate = "$prefix/bin", libDirTemplate = "$prefix/lib", libSubdirTemplate = "$pkgid/$compiler", libexecDirTemplate = "$prefix/libexec", progDirTemplate = "$libdir/hugs/programs", includeDirTemplate = "$libdir/$libsubdir/include", dataDirTemplate = "$prefix/share", dataSubdirTemplate = "$pkgid", docDirTemplate = "$datadir/doc/$pkgid", htmlDirTemplate = "$docdir/html"}, compiler = Compiler {compilerFlavor = GHC, compilerId = PackageIdentifier {pkgName = "ghc", pkgVersion = Version {versionBranch = [6,6], versionTags = []}}, compilerExtensions = [(OverlappingInstances,"-fallow-overlapping-instances"),(TypeSynonymInstances,"-fglasgow-exts"),(TemplateHaskell,"-fth"),(ForeignFunctionInterface,"-fffi"),(NoMonomorphismRestriction,"-fno-monomorphism-restriction"),(UndecidableInstances,"-fallow-undecidable-instances"),(IncoherentInstances,"-fallow-incoherent-instances"),(Arrows,"-farrows"),(Generics,"-fgenerics"),(NoImplicitPrelude,"-fno-implicit-prelude"),(ImplicitParams,"-fimplicit-params"),(CPP,"-cpp"),(BangPatterns,"-fbang-patterns"),(KindSignatures,"-fglasgow-exts"),(RecursiveDo,"-fglasgow-exts"),(ParallelListComp,"-fglasgow-exts"),(MultiParamTypeClasses,"-fglasgow-exts"),(FunctionalDependencies,"-fglasgow-exts"),(Rank2Types,"-fglasgow-exts"),(RankNTypes,"-fglasgow-exts"),(PolymorphicComponents,"-fglasgow-exts"),(ExistentialQuantification,"-fglasgow-exts"),(ScopedTypeVariables,"-fglasgow-exts"),(FlexibleContexts,"-fglasgow-exts"),(FlexibleInstances,"-fglasgow-exts"),(EmptyDataDecls,"-fglasgow-exts"),(PatternGuards,"-fglasgow-exts"),(GeneralizedNewtypeDeriving,"-fglasgow-exts"),(MagicHash,"-fglasgow-exts")]}, buildDir = "dist/build", scratchDir = "dist/scratch", packageDeps = [PackageIdentifier {pkgName = "base", pkgVersion = Version {versionBranch = [2,0], versionTags = []}},PackageIdentifier {pkgName = "haskell98", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}], localPkgDescr = PackageDescription {package = PackageIdentifier {pkgName = "hstats", pkgVersion = Version {versionBranch = [0,1], versionTags = []}}, license = BSD3, licenseFile = "LICENSE", copyright = "Copyright (c) 2007, SFTank", maintainer = "mbeddoe@<nospam>sftank.net", author = "Marshall Beddoe", stability = "", testedWith = [], homepage = "http://www.sftank.net", pkgUrl = "", synopsis = "Statistical Computing in Haskell", description = "A library of commonly used statistical functions", category = "Math", buildDepends = [Dependency "base" (UnionVersionRanges (ThisVersion (Version {versionBranch = [2,0], versionTags = []})) (LaterVersion (Version {versionBranch = [2,0], versionTags = []}))),Dependency "haskell98" AnyVersion], descCabalVersion = AnyVersion, buildType = Custom, library = Just (Library {exposedModules = ["Math.Statistics"], libBuildInfo = BuildInfo {buildable = True, buildTools = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = ["src"], otherModules = [], extensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [(GHC,["-O"])], ghcProfOptions = [], ghcSharedOptions = []}}), executables = [], dataFiles = [], extraSrcFiles = [], extraTmpFiles = []}, withPrograms = [("alex",ConfiguredProgram {programId = "alex", programVersion = Just (Version {versionBranch = [2,1,0], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/alex"}}),("ar",ConfiguredProgram {programId = "ar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ar"}}),("ffihugs",ConfiguredProgram {programId = "ffihugs", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/opt/local/bin/ffihugs"}}),("ghc",ConfiguredProgram {programId = "ghc", programVersion = Just (Version {versionBranch = [6,6], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/ghc"}}),("ghc-pkg",ConfiguredProgram {programId = "ghc-pkg", programVersion = Just (Version {versionBranch = [6,6], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/ghc-pkg"}}),("haddock",ConfiguredProgram {programId = "haddock", programVersion = Just (Version {versionBranch = [0,8], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/haddock"}}),("happy",ConfiguredProgram {programId = "happy", programVersion = Just (Version {versionBranch = [1,16], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/happy"}}),("hmake",ConfiguredProgram {programId = "hmake", programVersion = Just (Version {versionBranch = [3,13], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/hmake"}}),("hsc2hs",ConfiguredProgram {programId = "hsc2hs", programVersion = Just (Version {versionBranch = [0,66], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/hsc2hs"}}),("hugs",ConfiguredProgram {programId = "hugs", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/opt/local/bin/hugs"}}),("ld",ConfiguredProgram {programId = "ld", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ld"}}),("pkg-config",ConfiguredProgram {programId = "pkg-config", programVersion = Just (Version {versionBranch = [0,21], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/opt/local/bin/pkg-config"}}),("ranlib",ConfiguredProgram {programId = "ranlib", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ranlib"}}),("tar",ConfiguredProgram {programId = "tar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/tar"}})], withPackageDB = GlobalPackageDB, withVanillaLib = True, withProfLib = False, withSharedLib = False, withProfExe = False, withOptimization = True, withGHCiLib = True, splitObjs = False}
− _darcs/pristine/hstats.cabal
@@ -1,15 +0,0 @@-Name: hstats-Version: 0.1-License: BSD3-License-file: LICENSE-Author: Marshall Beddoe-Copyright: Copyright (c) 2007, SFTank-category: Math-synopsis: Statistical Computing in Haskell-description: A library of commonly used statistical functions-maintainer: mbeddoe@<nospam>sftank.net-homepage: http://www.sftank.net-hs-source-dirs: src-ghc-options: -O-exposed-Modules: Math.Statistics-build-depends: base>=2.0, haskell98
− _darcs/pristine/src/Math/Statistics.hs
@@ -1,108 +0,0 @@--------------------------------------------------------------------------------- Module : Math.Statistics--- Copyright : (c) 2007 SFTank--- License : BSD3------ Maintainer : mbeddoe@<nospam>sftank.net--- Stability : experimental--- Portability : portable------ Description :--- A collection of commonly used statistical functions.--------------------------------------------------------------------------------module Math.Statistics where--import List---- Arithmetic mean-mean :: (Floating a) => [a] -> a-mean xs = sum xs / (fromIntegral . length) xs---- Harmonic mean-hmean :: (Floating a) => [a] -> a-hmean xs = fromIntegral (length xs) / (sum $ map (1/) xs)---- Geometric mean-gmean :: (Floating a) => [a] -> a-gmean xs = (foldr1 (*) xs)**(1 / fromIntegral (length xs))---- Median-median :: (Floating a, Ord a) => [a] -> a-median x | odd n = head $ drop (n `div` 2) x'- | even n = mean $ take 2 $ drop i x'- where i = (length x' `div` 2) - 1- x' = sort x- n = length x---- Modes--- Returns a sorted list of modes in descending order-modes :: (Ord a) => [a] -> [(Int, a)]-modes xs = sortOn (negate.fst) $ map (\x->(length x, head x)) $ (group.sort) xs- where- sortOn :: Ord b => (a -> b) -> [a] -> [a]- sortOn f = sortBy (\x y -> compare (f x) (f y))---- Range-range :: (Num a, Ord a) => [a] -> a-range xs = maximum xs - minimum xs---- Average deviation-avgdev :: (Floating a) => [a] -> a-avgdev xs = mean $ map (\x -> abs(x - m)) xs- where- m = mean xs---- Standard Deviation-stddev :: (Floating a) => [a] -> a-stddev xs = sqrt $ var xs---- Population variance-pvar :: (Floating a) => [a] -> a-pvar xs = mean $ map (\x -> (x - m)^2) xs- where- m = mean xs---- Sample variance-var :: (Floating a) => [a] -> a-var xs = (sum $ map (\x -> (x - m)^2) xs) / (fromIntegral (length xs)-1)- where- m = mean xs---- Interquartile range--- XXX: Add case that takes into account even vs odd length-iqr xs = take (length xs - 2*q) $ drop q xs- where- q = ((length xs) + 1) `div` 4---- Kurtosis-kurtosis :: (Floating b) => [b] -> b-kurtosis xs = sum (map (\x -> ((x - m) / (stddev xs))^4) xs) / n - 3- where- m = mean xs- n = fromIntegral $ length $ xs---- Skew-skew :: (Floating a) => [a] -> a-skew xs = mean $ (map (\x -> ((x - (mean xs)) / (stddev xs))^3) xs)---- Covariance-cov :: (Floating a) => [a] -> [a] -> a-cov xs ys = sum (zipWith (*) (map f1 xs) (map f2 ys)) / (n - 1)- where- n = fromIntegral $ length $ xs- m1 = mean xs- m2 = mean ys- f1 = \x -> (x - m1)- f2 = \x -> (x - m2)---- Covariance matrix-covm :: (Floating a) => [[a]] -> [[a]]-covm xs = split' (length xs) cs- where- cs = [ cov a b | a <- xs, b <- xs]- split' n = unfoldr (\y -> if null y then Nothing else Just $ splitAt n y)---- Pearson's product-moment correlation coefficient-corr :: (Floating a) => [a] -> [a] -> a-corr x y = cov x y / (stddev x * stddev y)
− dist/build/HShstats-0.1.o
binary file changed (23984 → absent bytes)
− dist/build/Math/Statistics.hi
binary file changed (10802 → absent bytes)
− dist/build/Math/Statistics.o
binary file changed (28168 → absent bytes)
− dist/build/Math/Stats.hi
binary file changed (10316 → absent bytes)
− dist/build/Math/Stats.o
binary file changed (26836 → absent bytes)
− dist/build/autogen/Paths_hstats.hs
@@ -1,26 +0,0 @@-module Paths_hstats (- version,- getBinDir, getLibDir, getDataDir, getLibexecDir,- getDataFileName- ) where--import Data.Version--version :: Version-version = Version {versionBranch = [0,1], versionTags = []}--bindir, libdir, datadir, libexecdir :: FilePath--bindir = "/usr/local/bin"-libdir = "/usr/local/lib/hstats-0.1/ghc-6.6"-datadir = "/usr/local/share/hstats-0.1"-libexecdir = "/usr/local/libexec"--getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath-getBinDir = return bindir-getLibDir = return libdir-getDataDir = return datadir-getLibexecDir = return libexecdir--getDataFileName :: FilePath -> IO FilePath-getDataFileName name = return (datadir ++ "/" ++ name)
− dist/build/libHShstats-0.1.a
binary file changed (31096 → absent bytes)
− dist/installed-pkg-config
@@ -1,29 +0,0 @@-name: hstats-version: 0.1-license: BSD3-copyright: Copyright (c) 2007, SFTank-maintainer: mbeddoe@<nospam>sftank.net-stability:-homepage: http://www.sftank.net-package-url:-description: A library of commonly used statistical functions-category: Math-author: Marshall Beddoe-exposed: True-exposed-modules: Math.Statistics-hidden-modules:-import-dirs: /usr/local/lib/hstats-0.1/ghc-6.6-library-dirs: /usr/local/lib/hstats-0.1/ghc-6.6-hs-libraries: HShstats-0.1-extra-libraries:-extra-ghci-libraries:-include-dirs:-includes:-depends: base-2.0 haskell98-1.0-hugs-options:-cc-options:-ld-options:-framework-dirs:-frameworks:-haddock-interfaces: /usr/local/share/doc/hstats-0.1/html/hstats/hstats.haddock-haddock-html: /usr/local/share/doc/hstats-0.1/html/hstats
− dist/setup-config
@@ -1,1 +0,0 @@-LocalBuildInfo {installDirTemplates = InstallDirTemplates {prefixDirTemplate = "/usr/local", binDirTemplate = "$prefix/bin", libDirTemplate = "$prefix/lib", libSubdirTemplate = "$pkgid/$compiler", libexecDirTemplate = "$prefix/libexec", progDirTemplate = "$libdir/hugs/programs", includeDirTemplate = "$libdir/$libsubdir/include", dataDirTemplate = "$prefix/share", dataSubdirTemplate = "$pkgid", docDirTemplate = "$datadir/doc/$pkgid", htmlDirTemplate = "$docdir/html"}, compiler = Compiler {compilerFlavor = GHC, compilerId = PackageIdentifier {pkgName = "ghc", pkgVersion = Version {versionBranch = [6,6], versionTags = []}}, compilerExtensions = [(OverlappingInstances,"-fallow-overlapping-instances"),(TypeSynonymInstances,"-fglasgow-exts"),(TemplateHaskell,"-fth"),(ForeignFunctionInterface,"-fffi"),(NoMonomorphismRestriction,"-fno-monomorphism-restriction"),(UndecidableInstances,"-fallow-undecidable-instances"),(IncoherentInstances,"-fallow-incoherent-instances"),(Arrows,"-farrows"),(Generics,"-fgenerics"),(NoImplicitPrelude,"-fno-implicit-prelude"),(ImplicitParams,"-fimplicit-params"),(CPP,"-cpp"),(BangPatterns,"-fbang-patterns"),(KindSignatures,"-fglasgow-exts"),(RecursiveDo,"-fglasgow-exts"),(ParallelListComp,"-fglasgow-exts"),(MultiParamTypeClasses,"-fglasgow-exts"),(FunctionalDependencies,"-fglasgow-exts"),(Rank2Types,"-fglasgow-exts"),(RankNTypes,"-fglasgow-exts"),(PolymorphicComponents,"-fglasgow-exts"),(ExistentialQuantification,"-fglasgow-exts"),(ScopedTypeVariables,"-fglasgow-exts"),(FlexibleContexts,"-fglasgow-exts"),(FlexibleInstances,"-fglasgow-exts"),(EmptyDataDecls,"-fglasgow-exts"),(PatternGuards,"-fglasgow-exts"),(GeneralizedNewtypeDeriving,"-fglasgow-exts"),(MagicHash,"-fglasgow-exts")]}, buildDir = "dist/build", scratchDir = "dist/scratch", packageDeps = [PackageIdentifier {pkgName = "base", pkgVersion = Version {versionBranch = [2,0], versionTags = []}},PackageIdentifier {pkgName = "haskell98", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}], localPkgDescr = PackageDescription {package = PackageIdentifier {pkgName = "hstats", pkgVersion = Version {versionBranch = [0,1], versionTags = []}}, license = BSD3, licenseFile = "LICENSE", copyright = "Copyright (c) 2007, SFTank", maintainer = "mbeddoe@<nospam>sftank.net", author = "Marshall Beddoe", stability = "", testedWith = [], homepage = "http://www.sftank.net", pkgUrl = "", synopsis = "Statistical Computing in Haskell", description = "A library of commonly used statistical functions", category = "Math", buildDepends = [Dependency "base" (UnionVersionRanges (ThisVersion (Version {versionBranch = [2,0], versionTags = []})) (LaterVersion (Version {versionBranch = [2,0], versionTags = []}))),Dependency "haskell98" AnyVersion], descCabalVersion = AnyVersion, buildType = Custom, library = Just (Library {exposedModules = ["Math.Statistics"], libBuildInfo = BuildInfo {buildable = True, buildTools = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = ["src"], otherModules = [], extensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [(GHC,["-O"])], ghcProfOptions = [], ghcSharedOptions = []}}), executables = [], dataFiles = [], extraSrcFiles = [], extraTmpFiles = []}, withPrograms = [("alex",ConfiguredProgram {programId = "alex", programVersion = Just (Version {versionBranch = [2,1,0], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/alex"}}),("ar",ConfiguredProgram {programId = "ar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ar"}}),("ffihugs",ConfiguredProgram {programId = "ffihugs", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/opt/local/bin/ffihugs"}}),("ghc",ConfiguredProgram {programId = "ghc", programVersion = Just (Version {versionBranch = [6,6], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/ghc"}}),("ghc-pkg",ConfiguredProgram {programId = "ghc-pkg", programVersion = Just (Version {versionBranch = [6,6], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/ghc-pkg"}}),("haddock",ConfiguredProgram {programId = "haddock", programVersion = Just (Version {versionBranch = [0,8], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/haddock"}}),("happy",ConfiguredProgram {programId = "happy", programVersion = Just (Version {versionBranch = [1,16], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/happy"}}),("hmake",ConfiguredProgram {programId = "hmake", programVersion = Just (Version {versionBranch = [3,13], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/hmake"}}),("hsc2hs",ConfiguredProgram {programId = "hsc2hs", programVersion = Just (Version {versionBranch = [0,66], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/local/bin/hsc2hs"}}),("hugs",ConfiguredProgram {programId = "hugs", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/opt/local/bin/hugs"}}),("ld",ConfiguredProgram {programId = "ld", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ld"}}),("pkg-config",ConfiguredProgram {programId = "pkg-config", programVersion = Just (Version {versionBranch = [0,21], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/opt/local/bin/pkg-config"}}),("ranlib",ConfiguredProgram {programId = "ranlib", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ranlib"}}),("tar",ConfiguredProgram {programId = "tar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/tar"}})], withPackageDB = GlobalPackageDB, withVanillaLib = True, withProfLib = False, withSharedLib = False, withProfExe = False, withOptimization = True, withGHCiLib = True, splitObjs = False}
hstats.cabal view
@@ -1,5 +1,5 @@ Name: hstats-Version: 0.1+Version: 0.2 License: BSD3 License-file: LICENSE Author: Marshall Beddoe
src/Math/Statistics.hs view
@@ -15,9 +15,9 @@ import List --- Arithmetic mean-mean :: (Floating a) => [a] -> a-mean xs = sum xs / (fromIntegral . length) xs+-- Numerically stable mean+mean :: Floating a => [a] -> a+mean = fst.foldr (\x (m,n) -> (m+(x-m) / (fromIntegral $ n + 1), n + 1)) (0,0) -- Harmonic mean hmean :: (Floating a) => [a] -> a@@ -43,6 +43,13 @@ sortOn :: Ord b => (a -> b) -> [a] -> [a] sortOn f = sortBy (\x y -> compare (f x) (f y)) +-- Central moments+centralMoment xs 1 = 0+centralMoment xs r = (sum (map (\x -> (x-m)^r) xs)) / n+ where+ m = mean xs+ n = fromIntegral $ length xs+ -- Range range :: (Num a, Ord a) => [a] -> a range xs = maximum xs - minimum xs@@ -53,21 +60,22 @@ where m = mean xs --- Standard Deviation+-- Standard deviation stddev :: (Floating a) => [a] -> a stddev xs = sqrt $ var xs -- Population variance pvar :: (Floating a) => [a] -> a-pvar xs = mean $ map (\x -> (x - m)^2) xs- where- m = mean xs+pvar xs = centralMoment xs 2 --- Sample variance-var :: (Floating a) => [a] -> a-var xs = (sum $ map (\x -> (x - m)^2) xs) / (fromIntegral (length xs)-1)+-- Numerically stable sample variance+var xs = (var' 0 0 0 xs) / (fromIntegral $ length xs - 1) where- m = mean xs+ var' _ _ s [] = s+ var' m n s (x:xs) = var' nm (n + 1) (s + delta * (x - nm)) xs+ where+ delta = x - m+ nm = m + delta/(fromIntegral $ n + 1) -- Interquartile range -- XXX: Add case that takes into account even vs odd length@@ -76,16 +84,17 @@ q = ((length xs) + 1) `div` 4 -- Kurtosis-kurtosis :: (Floating b) => [b] -> b-kurtosis xs = sum (map (\x -> ((x - m) / (stddev xs))^4) xs) / n - 3- where- m = mean xs- n = fromIntegral $ length $ xs+kurtosis xs = ((centralMoment xs 4) / (centralMoment xs 2)^2)-3 -- Skew-skew :: (Floating a) => [a] -> a-skew xs = mean $ (map (\x -> ((x - (mean xs)) / (stddev xs))^3) xs)+skew xs = (centralMoment xs 3) / (centralMoment xs 2)**(3/2) +pearsonSkew1 xs = 3 * (mean xs - mo) / stddev xs+ where+ mo = snd $ head $ modes xs++pearsonSkew2 xs = 3 * (mean xs - median xs) / stddev xs+ -- Covariance cov :: (Floating a) => [a] -> [a] -> a cov xs ys = sum (zipWith (*) (map f1 xs) (map f2 ys)) / (n - 1)@@ -97,8 +106,8 @@ f2 = \x -> (x - m2) -- Covariance matrix-covm :: (Floating a) => [[a]] -> [[a]]-covm xs = split' (length xs) cs+covMatrix :: (Floating a) => [[a]] -> [[a]]+covMatrix xs = split' (length xs) cs where cs = [ cov a b | a <- xs, b <- xs] split' n = unfoldr (\y -> if null y then Nothing else Just $ splitAt n y)@@ -106,3 +115,4 @@ -- Pearson's product-moment correlation coefficient corr :: (Floating a) => [a] -> [a] -> a corr x y = cov x y / (stddev x * stddev y)+