diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+* 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.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/_darcs/inventory b/_darcs/inventory
new file mode 100644
--- /dev/null
+++ b/_darcs/inventory
@@ -0,0 +1,2 @@
+[initial commit.
+mbeddoe@sftank.net**20070918213154] 
diff --git a/_darcs/patches/20070918213154-0e28a-c3676cccf964045a487682ba14406a05656b4001.gz b/_darcs/patches/20070918213154-0e28a-c3676cccf964045a487682ba14406a05656b4001.gz
new file mode 100644
Binary files /dev/null and b/_darcs/patches/20070918213154-0e28a-c3676cccf964045a487682ba14406a05656b4001.gz differ
diff --git a/_darcs/patches/pending b/_darcs/patches/pending
new file mode 100644
--- /dev/null
+++ b/_darcs/patches/pending
@@ -0,0 +1,2 @@
+{
+}
diff --git a/_darcs/prefs/author b/_darcs/prefs/author
new file mode 100644
--- /dev/null
+++ b/_darcs/prefs/author
@@ -0,0 +1,1 @@
+mbeddoe@sftank.net
diff --git a/_darcs/prefs/binaries b/_darcs/prefs/binaries
new file mode 100644
--- /dev/null
+++ b/_darcs/prefs/binaries
@@ -0,0 +1,59 @@
+# 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$
diff --git a/_darcs/prefs/boring b/_darcs/prefs/boring
new file mode 100644
--- /dev/null
+++ b/_darcs/prefs/boring
@@ -0,0 +1,49 @@
+# 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$
diff --git a/_darcs/prefs/motd b/_darcs/prefs/motd
new file mode 100644
--- /dev/null
+++ b/_darcs/prefs/motd
diff --git a/_darcs/pristine/LICENSE b/_darcs/pristine/LICENSE
new file mode 100644
--- /dev/null
+++ b/_darcs/pristine/LICENSE
@@ -0,0 +1,24 @@
+* 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.
diff --git a/_darcs/pristine/Setup.hs b/_darcs/pristine/Setup.hs
new file mode 100644
--- /dev/null
+++ b/_darcs/pristine/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/_darcs/pristine/dist/build/autogen/Paths_hstats.hs b/_darcs/pristine/dist/build/autogen/Paths_hstats.hs
new file mode 100644
--- /dev/null
+++ b/_darcs/pristine/dist/build/autogen/Paths_hstats.hs
@@ -0,0 +1,26 @@
+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)
diff --git a/_darcs/pristine/dist/installed-pkg-config b/_darcs/pristine/dist/installed-pkg-config
new file mode 100644
--- /dev/null
+++ b/_darcs/pristine/dist/installed-pkg-config
@@ -0,0 +1,29 @@
+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
diff --git a/_darcs/pristine/dist/setup-config b/_darcs/pristine/dist/setup-config
new file mode 100644
--- /dev/null
+++ b/_darcs/pristine/dist/setup-config
@@ -0,0 +1,1 @@
+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}
diff --git a/_darcs/pristine/hstats.cabal b/_darcs/pristine/hstats.cabal
new file mode 100644
--- /dev/null
+++ b/_darcs/pristine/hstats.cabal
@@ -0,0 +1,15 @@
+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
diff --git a/_darcs/pristine/src/Math/Statistics.hs b/_darcs/pristine/src/Math/Statistics.hs
new file mode 100644
--- /dev/null
+++ b/_darcs/pristine/src/Math/Statistics.hs
@@ -0,0 +1,108 @@
+-----------------------------------------------------------------------------
+-- 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)
diff --git a/dist/build/HShstats-0.1.o b/dist/build/HShstats-0.1.o
new file mode 100644
Binary files /dev/null and b/dist/build/HShstats-0.1.o differ
diff --git a/dist/build/Math/Statistics.hi b/dist/build/Math/Statistics.hi
new file mode 100644
Binary files /dev/null and b/dist/build/Math/Statistics.hi differ
diff --git a/dist/build/Math/Statistics.o b/dist/build/Math/Statistics.o
new file mode 100644
Binary files /dev/null and b/dist/build/Math/Statistics.o differ
diff --git a/dist/build/Math/Stats.hi b/dist/build/Math/Stats.hi
new file mode 100644
Binary files /dev/null and b/dist/build/Math/Stats.hi differ
diff --git a/dist/build/Math/Stats.o b/dist/build/Math/Stats.o
new file mode 100644
Binary files /dev/null and b/dist/build/Math/Stats.o differ
diff --git a/dist/build/autogen/Paths_hstats.hs b/dist/build/autogen/Paths_hstats.hs
new file mode 100644
--- /dev/null
+++ b/dist/build/autogen/Paths_hstats.hs
@@ -0,0 +1,26 @@
+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)
diff --git a/dist/build/libHShstats-0.1.a b/dist/build/libHShstats-0.1.a
new file mode 100644
Binary files /dev/null and b/dist/build/libHShstats-0.1.a differ
diff --git a/dist/installed-pkg-config b/dist/installed-pkg-config
new file mode 100644
--- /dev/null
+++ b/dist/installed-pkg-config
@@ -0,0 +1,29 @@
+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
diff --git a/dist/setup-config b/dist/setup-config
new file mode 100644
--- /dev/null
+++ b/dist/setup-config
@@ -0,0 +1,1 @@
+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}
diff --git a/hstats.cabal b/hstats.cabal
new file mode 100644
--- /dev/null
+++ b/hstats.cabal
@@ -0,0 +1,15 @@
+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
diff --git a/src/Math/Statistics.hs b/src/Math/Statistics.hs
new file mode 100644
--- /dev/null
+++ b/src/Math/Statistics.hs
@@ -0,0 +1,108 @@
+-----------------------------------------------------------------------------
+-- 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)
