packages feed

statistics 0.3.1 → 0.3.2

raw patch · 3 files changed

+22/−9 lines, 3 files

Files

Statistics/Distribution/Normal.hs view
@@ -23,7 +23,7 @@ import Control.Exception (assert) import Data.Number.Erf (erfc) import Data.Typeable (Typeable)-import Statistics.Constants (m_huge, m_sqrt_2, m_sqrt_2_pi)+import Statistics.Constants (m_sqrt_2, m_sqrt_2_pi) import qualified Statistics.Distribution as D import qualified Statistics.Sample as S @@ -76,8 +76,10 @@  quantile :: NormalDistribution -> Double -> Double quantile d p-  | p == 0    = -m_huge-  | p == 1    = m_huge-  | p == 0.5  = mean d-  | otherwise = x * sqrt (variance d) + mean d-  where x     = D.findRoot standard p 0 (-100) 100+  | 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/Function.hs view
@@ -15,11 +15,13 @@       minMax     , sort     , partialSort+    -- * Array setup     , createU+    , createIO     ) where  import Control.Exception (assert)-import Control.Monad.ST (ST)+import Control.Monad.ST (ST, unsafeIOToST, unsafeSTToIO) import Data.Array.Vector.Algorithms.Combinators (apply) import Data.Array.Vector import qualified Data.Array.Vector.Algorithms.Intro as I@@ -48,7 +50,8 @@     fini (MM lo hi) = lo :*: hi {-# INLINE minMax #-} --- | Create an array, using the given action to populate each element.+-- | Create an array, using the given 'ST' action to populate each+-- element. createU :: (UA e) => forall s. Int -> (Int -> ST s e) -> ST s (UArr e) createU size itemAt = assert (size >= 0) $     newMU size >>= loop 0@@ -58,3 +61,11 @@       r <- itemAt k       writeMU arr k r       loop (k+1) arr+{-# INLINE createU #-}++-- | Create an array, using the given 'IO' action to populate each+-- element.+createIO :: (UA e) => Int -> (Int -> IO e) -> IO (UArr e)+createIO size itemAt =+    unsafeSTToIO $ createU size (unsafeIOToST . itemAt)+{-# INLINE createIO #-}
statistics.cabal view
@@ -1,5 +1,5 @@ name:           statistics-version:        0.3.1+version:        0.3.2 synopsis:       A library of statistical types, data, and functions description:   This library provides a number of common functions and types useful