HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulestatistics-0.16.3.0Haskell2010

Statistics.Types

Data types common used in statistics

  • 10 types
  • 1 class
  • 22 values

Confidence level

1 declaration
newtypenewtype CL a
#

Confidence level. In context of confidence intervals it's probability of said interval covering true value of measured value. In context of statistical tests it's 1-α where α is significance of test.

Since confidence level are usually close to 1 they are stored as 1-CL internally. There are two smart constructors for CL: mkCL and mkCLFromSignificance (and corresponding variant returning Maybe). First creates CL from confidence level and second from 1 - CL or significance level.

Example1 expression
cl95mkCLFromSignificance 5.0e-2

Prior to 0.14 confidence levels were passed to function as plain Doubles. Use mkCL to convert them to CL.

Instances16Eq, Data, Ord, Read, Show, Generic, …

Accessors

Constructors

valuemkCL :: (Ord a, Num a) => a -> CL a
#

Create confidence level from probability β or probability confidence interval contain true value of estimate. Will throw exception if parameter is out of [0,1] range

Example1 expression
mkCL 0.95    -- same as cl95mkCLFromSignificance 5.0000000000000044e-2
valuemkCLE :: (Ord a, Num a) => a -> Maybe (CL a)
#

Same as mkCL but returns Nothing instead of error if parameter is out of [0,1] range

Example1 expression
mkCLE 0.95    -- same as cl95Just (mkCLFromSignificance 5.0000000000000044e-2)
valuemkCLFromSignificance :: (Ord a, Num a) => a -> CL a
#

Create confidence level from probability α or probability that confidence interval does not contain true value of estimate. Will throw exception if parameter is out of [0,1] range

Example1 expression
mkCLFromSignificance 0.05    -- same as cl95mkCLFromSignificance 5.0e-2

Constants and conversion to nσ

Normal approximation

valuenSigma :: Double -> PValue Double
#

P-value expressed in sigma. This is convention widely used in experimental physics. N sigma confidence level corresponds to probability within N sigma of normal distribution.

Note that this correspondence is for normal distribution. Other distribution will have different dependency. Also experimental distribution usually only approximately normal (especially at extreme tails).

valuenSigma1 :: Double -> PValue Double
#

P-value expressed in sigma for one-tail hypothesis. This correspond to probability of obtaining value less than N·σ.

p-value

1 declaration
newtypenewtype PValue a
#

Newtype wrapper for p-value.

Instances16Eq, Data, Ord, Read, Show, Generic, …

Accessors

Constructors

valuemkPValue :: (Ord a, Num a) => a -> PValue a
#

Construct PValue. Throws error if argument is out of [0,1] range.

Estimates and upper/lower limits

5 declarations
datadata Estimate (e :: Type -> Type) a
#

A point estimate and its confidence interval. It's parametrized by both error type e and value type a. This module provides two types of error: NormalErr for normally distributed errors and ConfInt for error with normal distribution. See their documentation for more details.

For example 144 ± 5 (assuming normality) could be expressed as

Estimate { estPoint = 144
         , estError = NormalErr 5
         }

Or if we want to express 144 + 6 - 4 at CL95 we could write:

Estimate { estPoint = 144
         , estError = ConfInt
                      { confIntLDX = 4
                      , confIntUDX = 6
                      , confIntCL  = cl95
                      }
         }

Prior to statistics 0.14 Estimate data type used following definition:

data Estimate = Estimate {
     estPoint           :: {-# UNPACK #-} !Double
   , estLowerBound      :: {-# UNPACK #-} !Double
   , estUpperBound      :: {-# UNPACK #-} !Double
   , estConfidenceLevel :: {-# UNPACK #-} !Double
   }

Now type Estimate ConfInt Double should be used instead. Function estimateFromInterval allow to easily construct estimate from same inputs.

Constructors

Instances16Scale, Eq, Data, Read, Show, Generic, …
newtypenewtype NormalErr a
#

Normal errors. They are stored as 1σ errors which corresponds to 68.8% CL. Since we can recalculate them to any confidence level if needed we don't store it.

Constructors

Instances16Scale, Eq, Data, Read, Show, Generic, …
datadata ConfInt a
#

Confidence interval. It assumes that confidence interval forms single interval and isn't set of disjoint intervals.

Constructors

  • ConfInt
    • confIntLDX :: !a

      Lower error estimate, or distance between point estimate and lower bound of confidence interval.

    • confIntUDX :: !a

      Upper error estimate, or distance between point estimate and upper bound of confidence interval.

    • confIntCL :: !CL Double

      Confidence level corresponding to given confidence interval.

Instances16Scale, Eq, Data, Read, Show, Generic, …
datadata UpperLimit a
#

Upper limit. They are usually given for small non-negative values when it's not possible detect difference from zero.

Constructors

Instances15Eq, Data, Read, Show, Generic, NFData, …
datadata LowerLimit a
#

Lower limit. They are usually given for large quantities when it's not possible to measure them. For example: proton half-life

Constructors

Instances15Eq, Data, Read, Show, Generic, NFData, …

Constructors

valueestimateFromInterval
  1. :: Num a
  2. => a

    Point estimate. Should lie within interval but it's not checked.

  3. -> (a, a)

    Lower and upper bounds of interval

  4. -> CL Double

    Confidence level for interval

  5. -> Estimate ConfInt a
#

Create estimate with asymmetric error.

valueestimateFromErr
  1. :: a

    Central estimate

  2. -> (a, a)

    Lower and upper errors. Both should be positive but it's not checked.

  3. -> CL Double

    Confidence level for interval

  4. -> Estimate ConfInt a
#

Create estimate with asymmetric error.

Accessors

classclass Scale (e :: Type -> Type) where
#

Data types which could be multiplied by constant.

Methods

Instances3Scale

Other

3 declarations