packages feed

statistics 0.8.0.2 → 0.8.0.3

raw patch · 6 files changed

+55/−253 lines, 6 files

Files

− README
@@ -1,47 +0,0 @@-Statistics: efficient, general purpose statistics----------------------------------------------------This package provides the Statistics module, a Haskell library for-working with statistical data in a space- and time-efficient way.--Where possible, we give citations and computational complexity-estimates for the algorithms used.---Performance--------------This library has been carefully optimised for high performance.  To-obtain the best runtime efficiency, it is imperative to compile-libraries and applications that use this library using a high level of-optimisation.--Suggested GHC options:--  -O -fvia-C -funbox-strict-fields--To illustrate, here are the times (in seconds) to generate and sum 250-million random Word32 values, on a laptop with a 2.4GHz Core2 Duo-P8600 processor, running Fedora 11 and GHC 6.10.3:--  no flags   200+-  -O           1.249-  -O -fvia-C   0.991--As the numbers above suggest, compiling without optimisation will-yield unacceptable performance.---Get involved!----------------Please feel welcome to contribute new code or bug fixes.  You can-fetch the source repository from here:--http://bitbucket.org/bos/statistics---Authors----------Bryan O'Sullivan <bos@serpentine.com>
+ README.markdown view
@@ -0,0 +1,52 @@+# Statistics: efficient, general purpose statistics++This package provides the Statistics module, a Haskell library for+working with statistical data in a space- and time-efficient way.++Where possible, we give citations and computational complexity+estimates for the algorithms used.+++# Performance++This library has been carefully optimised for high performance.  To+obtain the best runtime efficiency, it is imperative to compile+libraries and applications that use this library using a high level of+optimisation.++Suggested GHC options:++    -O -funbox-strict-fields++To illustrate, here are the times (in seconds) to generate and sum 250+million random Word32 values, on a laptop with a 2.4GHz Core2 Duo+P8600 processor, running Fedora 11 and GHC 6.10.3:++    no flags   200++    -O           1.249+    -O -fvia-C   0.991++As the numbers above suggest, compiling without optimisation will+yield unacceptable performance.+++# Get involved!++Please report bugs via the+[bitbucket issue tracker](http://bitbucket.org/bos/attoparsec/statistics).++Master [Mercurial repository](http://bitbucket.org/bos/statistics):++* `hg clone http://bitbucket.org/bos/statistics`++There's also a [git mirror](http://github.com/bos/statistics):++* `git clone git://github.com/bos/statistics.git`++(You can create and contribute changes using either Mercurial or git.)+++# Authors++This library is written and maintained by Bryan O'Sullivan,+<bos@serpentine.com>.
− Statistics/Distribution/Beta.hs
@@ -1,51 +0,0 @@-{-# LANGUAGE DeriveDataTypeable #-}--- |--- Module    : Statistics.Distribution.Beta--- Copyright : (c) 2010 Karamaan Group------ The beta distribution.--module Statistics.Distribution.Beta-    (-      BetaDistribution-    -- * Constructors-    , fromParams-    -- * Accessors-    , tridistA-    , tridistB-    , tridistC-    ) where--import Control.Exception-import Data.Generics-import Foreign.C.Math.Double (gamma)-import qualified Statistics.Distribution as D--data BetaDistribution = BetaDist {-  alpha :: Double,-  beta :: Double-} deriving (Eq, Read, Show, Typeable, Data)--instance D.Distribution BetaDistribution where-  density (BetaDist a b) x = (gamma (a+b) / (gamma a * gamma b)) *-    (x**(a-1)) * ((1-x)**(b-1))-  {-# INLINE density #-}-  cumulative (BetaDist a b) x = undefined-  {-# INLINE cumulative #-}-  quantile (BetaDist a b) p = undefined-  {-# INLINE quantile #-}--instance D.Variance BetaDistribution where-    variance (BetaDist a b) = (a * b) /-      ((a+b)^2 * (a + b + 1))-    {-# INLINE variance #-}--instance D.Mean BetaDistribution where-    mean (BetaDist a b) = a / (a + b)-    {-# INLINE mean #-}--fromParams :: Double -> Double -> BetaDistribution-fromParams a b = assert (a > 0 && b > 0) (BetaDist a b)-{-# INLINE fromParams #-}--
− Statistics/Distribution/LogNormal.hs
@@ -1,81 +0,0 @@-{-# LANGUAGE DeriveDataTypeable #-}--- |--- Module    : Statistics.Distribution.LogNormal--- Copyright : (c) 2009 Karamaan Group------ The lognormal distribution. This is the distribution of a random --- variable whose logarithm is normally distributed.--module Statistics.Distribution.LogNormal-    (-      LogNormalDistribution-    -- * Constructors-    , fromParams-    , standard-    ) where--import Control.Exception (assert)-import Data.Number.Erf (erf)-import Data.Generics-import Statistics.Constants (m_sqrt_2, m_sqrt_2_pi)-import qualified Statistics.Distribution as D---- | The lognormal distribution.-data LogNormalDistribution = ND {-      mean     :: {-# UNPACK #-} !Double-    , variance :: {-# UNPACK #-} !Double-    , ndPdfDenom :: {-# UNPACK #-} !Double-    , ndCdfDenom :: {-# UNPACK #-} !Double-    } deriving (Eq, Read, Show, Typeable, Data)--instance D.Distribution LogNormalDistribution where-    density    = density-    cumulative = cumulative-    quantile   = quantile--instance D.Variance LogNormalDistribution where-    variance = variance--instance D.Mean LogNormalDistribution where-    mean = mean--standard :: LogNormalDistribution-standard = ND {-             mean = 0.0-           , variance = 1.0-           , ndPdfDenom = m_sqrt_2_pi-           , ndCdfDenom = m_sqrt_2-           }--fromParams :: Double -> Double -> LogNormalDistribution-fromParams m v = assert (v > 0)-                 ND {-                   mean = m-                 , variance = v-                 , ndPdfDenom = m_sqrt_2_pi * sv-                 , ndCdfDenom = m_sqrt_2 * sv-                 }-    where sv = sqrt v--density :: LogNormalDistribution -> Double -> Double-density d x = exp (-xm * xm / (2 * variance d)) / (x * ndPdfDenom d)-    where xm = log x - mean d--cumulative :: LogNormalDistribution -> Double -> Double-cumulative d x = (1 + erf ((log x-mean d) / ndCdfDenom d)) / 2---- | This is the quantile function for the LogNormalDistribution.-quantile :: LogNormalDistribution -> Double -> Double-quantile d p = exp $ quantile' d p---- | This is the quantile function for NormalDistribution.-quantile' :: LogNormalDistribution -> Double -> Double-quantile' d p-  | p < 0 || p > 1 = inf/inf-  | p == 0         = -inf-  | p == 1         = inf-  | p == 0.5       = mean d-  | otherwise      = x * sqrt (variance d) + mean d-  where x          = D.findRoot standard p 0 (-100) 100-        inf        = 1/0-
− Statistics/Distribution/Triangular.hs
@@ -1,68 +0,0 @@-{-# LANGUAGE DeriveDataTypeable #-}--- |--- Module    : Statistics.Distribution.Triangular--- Copyright : (c) 2010 Karamaan Group------ The triangular distribution. This is the distribution of a random --- variable with lower limit a, mode c and upper limit b.--module Statistics.Distribution.Triangular-    (-      TriangularDistribution-    -- * Constructors-    , fromParams-    -- * Accessors-    , tridistA-    , tridistB-    , tridistC-    ) where--import Data.Generics-import qualified Statistics.Distribution as D--data TriangularDistribution = TriDist {-  tridistA :: Double, -- min-  tridistB :: Double, -- max-  tridistC :: Double  -- mode-} deriving (Eq, Read, Show, Typeable, Data)--instance D.Distribution TriangularDistribution where-  density (TriDist a b c) x-    | (a <= x) && (x <= c) = (2 * (x - a)) / ((b - a) * (c - a))-    | (c <= x) && (x <= b) = (2 * (b - x)) / ((b - a) * (b - c))-    | otherwise         = 0-  {-# INLINE density #-}--  cumulative (TriDist a b c) x-    | a > x             = 0-    | (a <= x) && (x <= c) = ((x - a) ^ 2) / ((b - a) * (c - a))-    | (c <= x) && (x <= b) = 1 - ((b - x) ^ 2) / ((b - a) * (b - c))-    | otherwise         = 1-  {-# INLINE cumulative #-}--  quantile (TriDist a b c) p   = calc ((c - a) / (b - a))-    where calc p0-            | p < p0    = sqrt ((b-a) * (c-a) * p) + a-            | p == p0   = c-            | otherwise = b - sqrt ((b-a) * (b-c) * (1-p))-  {-# INLINE quantile #-}--instance D.Variance TriangularDistribution where-    variance (TriDist a b c) =-      (a^2 + b^2 + c^2 - (a*b) - (a*c) - (b*c)) / 18-    {-# INLINE variance #-}--instance D.Mean TriangularDistribution where-    mean (TriDist a b c) = (a + b + c) / 3-    {-# INLINE mean #-}--fromParams :: Double -> Double -> Double -> TriangularDistribution-fromParams a b c -    | (c > b) || (c < a) = error $ "Triangular Distribution: Parameter " ++ (show c)-                          ++ " is expected to be between the parameters " -                          ++ (show a) ++ " and " ++ (show b) ++ "."-    | b < a             = error $ "Triangular Distribution: Parameter " ++ (show b)-                          ++ " is expected to be greater than parameter " ++ (show a) ++ "."-    | otherwise         = TriDist a b c-{-# INLINE fromParams #-}-
statistics.cabal view
@@ -1,5 +1,5 @@ name:           statistics-version:        0.8.0.2+version:        0.8.0.3 synopsis:       A library of statistical types, data, and functions description:   This library provides a number of common functions and types useful@@ -30,24 +30,21 @@ category:       Math, Statistics build-type:     Simple cabal-version:  >= 1.6-extra-source-files: README+extra-source-files: README.markdown  library   exposed-modules:     Statistics.Autocorrelation     Statistics.Constants     Statistics.Distribution-    Statistics.Distribution.Beta     Statistics.Distribution.Binomial     Statistics.Distribution.ChiSquared-    Statistics.Distribution.Exponential     Statistics.Distribution.Gamma     Statistics.Distribution.Geometric+    Statistics.Distribution.Exponential     Statistics.Distribution.Hypergeometric-    Statistics.Distribution.LogNormal     Statistics.Distribution.Normal     Statistics.Distribution.Poisson-    Statistics.Distribution.Triangular     Statistics.Function     Statistics.KernelDensity     Statistics.Math