    {-# LANGUAGE DeriveFunctor, DeriveDataTypeable,DeriveGeneric  #-}
    module Statistics.Test.Types (
        Test(..)
      , isSignificant
      , TestResult(..)
      , significant
      , PositionTest(..)
      ) where

    import Control.DeepSeq  (NFData(..))
    import Control.Monad    (liftM3)
    import Data.Aeson       (FromJSON, ToJSON)
    import Data.Binary      (Binary (..))
    import Data.Data (Typeable, Data)
    import GHC.Generics

    import Statistics.Types (PValue)

    -- | Result of hypothesis testing
    data TestResult = Significant    -- ^ Null hypothesis should be rejected
                    | NotSignificant -- ^ Data is compatible with hypothesis
                      deriving (TestResult -> TestResult -> Bool
    (TestResult -> TestResult -> Bool)
    -> (TestResult -> TestResult -> Bool) -> Eq TestResult
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TestResult -> TestResult -> Bool
    == :: TestResult -> TestResult -> Bool
    $c/= :: TestResult -> TestResult -> Bool
    /= :: TestResult -> TestResult -> Bool
    Eq,Eq TestResult
    Eq TestResult =>
    (TestResult -> TestResult -> Ordering)
    -> (TestResult -> TestResult -> Bool)
    -> (TestResult -> TestResult -> Bool)
    -> (TestResult -> TestResult -> Bool)
    -> (TestResult -> TestResult -> Bool)
    -> (TestResult -> TestResult -> TestResult)
    -> (TestResult -> TestResult -> TestResult)
    -> Ord TestResult
    TestResult -> TestResult -> Bool
    TestResult -> TestResult -> Ordering
    TestResult -> TestResult -> TestResult
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: TestResult -> TestResult -> Ordering
    compare :: TestResult -> TestResult -> Ordering
    $c< :: TestResult -> TestResult -> Bool
    < :: TestResult -> TestResult -> Bool
    $c<= :: TestResult -> TestResult -> Bool
    <= :: TestResult -> TestResult -> Bool
    $c> :: TestResult -> TestResult -> Bool
    > :: TestResult -> TestResult -> Bool
    $c>= :: TestResult -> TestResult -> Bool
    >= :: TestResult -> TestResult -> Bool
    $cmax :: TestResult -> TestResult -> TestResult
    max :: TestResult -> TestResult -> TestResult
    $cmin :: TestResult -> TestResult -> TestResult
    min :: TestResult -> TestResult -> TestResult
    Ord,Int -> TestResult -> ShowS
    [TestResult] -> ShowS
    TestResult -> String
    (Int -> TestResult -> ShowS)
    -> (TestResult -> String)
    -> ([TestResult] -> ShowS)
    -> Show TestResult
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TestResult -> ShowS
    showsPrec :: Int -> TestResult -> ShowS
    $cshow :: TestResult -> String
    show :: TestResult -> String
    $cshowList :: [TestResult] -> ShowS
    showList :: [TestResult] -> ShowS
    Show,Typeable,Typeable TestResult
    Typeable TestResult =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> TestResult -> c TestResult)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c TestResult)
    -> (TestResult -> Constr)
    -> (TestResult -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c TestResult))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c TestResult))
    -> ((forall b. Data b => b -> b) -> TestResult -> TestResult)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> TestResult -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> TestResult -> r)
    -> (forall u. (forall d. Data d => d -> u) -> TestResult -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> TestResult -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> TestResult -> m TestResult)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> TestResult -> m TestResult)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> TestResult -> m TestResult)
    -> Data TestResult
    TestResult -> Constr
    TestResult -> DataType
    (forall b. Data b => b -> b) -> TestResult -> TestResult
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> TestResult -> u
    forall u. (forall d. Data d => d -> u) -> TestResult -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TestResult -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TestResult -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TestResult
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TestResult -> c TestResult
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TestResult)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestResult)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TestResult -> c TestResult
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TestResult -> c TestResult
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TestResult
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TestResult
    $ctoConstr :: TestResult -> Constr
    toConstr :: TestResult -> Constr
    $cdataTypeOf :: TestResult -> DataType
    dataTypeOf :: TestResult -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TestResult)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TestResult)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestResult)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestResult)
    $cgmapT :: (forall b. Data b => b -> b) -> TestResult -> TestResult
    gmapT :: (forall b. Data b => b -> b) -> TestResult -> TestResult
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TestResult -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TestResult -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TestResult -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TestResult -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> TestResult -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> TestResult -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TestResult -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TestResult -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TestResult -> m TestResult
    Data,(forall x. TestResult -> Rep TestResult x)
    -> (forall x. Rep TestResult x -> TestResult) -> Generic TestResult
    forall x. Rep TestResult x -> TestResult
    forall x. TestResult -> Rep TestResult x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TestResult -> Rep TestResult x
    from :: forall x. TestResult -> Rep TestResult x
    $cto :: forall x. Rep TestResult x -> TestResult
    to :: forall x. Rep TestResult x -> TestResult
    Generic)

    instance Binary   TestResult where
      get :: Get TestResult
    get = do
          sig <- Get Bool
    forall t. Binary t => Get t
    get
          if sig then return Significant else return NotSignificant
      put :: TestResult -> Put
    put = Bool -> Put
    forall t. Binary t => t -> Put
    put (Bool -> Put) -> (TestResult -> Bool) -> TestResult -> Put
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (TestResult -> TestResult -> Bool
    forall a. Eq a => a -> a -> Bool
    == TestResult
    Significant)
    instance FromJSON TestResult
    instance ToJSON   TestResult
    instance NFData   TestResult

    -- | Result of statistical test.
    data Test distr = Test
      { forall distr. Test distr -> PValue Double
    testSignificance :: !(PValue Double)
        -- ^ Probability of getting value of test statistics at least as
        --   extreme as measured.
      , forall distr. Test distr -> Double
    testStatistics   :: !Double
        -- ^ Statistic used for test.
      , forall distr. Test distr -> distr
    testDistribution :: distr
        -- ^ Distribution of test statistics if null hypothesis is correct.
      }
      deriving (Test distr -> Test distr -> Bool
    (Test distr -> Test distr -> Bool)
    -> (Test distr -> Test distr -> Bool) -> Eq (Test distr)
    forall distr. Eq distr => Test distr -> Test distr -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: forall distr. Eq distr => Test distr -> Test distr -> Bool
    == :: Test distr -> Test distr -> Bool
    $c/= :: forall distr. Eq distr => Test distr -> Test distr -> Bool
    /= :: Test distr -> Test distr -> Bool
    Eq,Eq (Test distr)
    Eq (Test distr) =>
    (Test distr -> Test distr -> Ordering)
    -> (Test distr -> Test distr -> Bool)
    -> (Test distr -> Test distr -> Bool)
    -> (Test distr -> Test distr -> Bool)
    -> (Test distr -> Test distr -> Bool)
    -> (Test distr -> Test distr -> Test distr)
    -> (Test distr -> Test distr -> Test distr)
    -> Ord (Test distr)
    Test distr -> Test distr -> Bool
    Test distr -> Test distr -> Ordering
    Test distr -> Test distr -> Test distr
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    forall distr. Ord distr => Eq (Test distr)
    forall distr. Ord distr => Test distr -> Test distr -> Bool
    forall distr. Ord distr => Test distr -> Test distr -> Ordering
    forall distr. Ord distr => Test distr -> Test distr -> Test distr
    $ccompare :: forall distr. Ord distr => Test distr -> Test distr -> Ordering
    compare :: Test distr -> Test distr -> Ordering
    $c< :: forall distr. Ord distr => Test distr -> Test distr -> Bool
    < :: Test distr -> Test distr -> Bool
    $c<= :: forall distr. Ord distr => Test distr -> Test distr -> Bool
    <= :: Test distr -> Test distr -> Bool
    $c> :: forall distr. Ord distr => Test distr -> Test distr -> Bool
    > :: Test distr -> Test distr -> Bool
    $c>= :: forall distr. Ord distr => Test distr -> Test distr -> Bool
    >= :: Test distr -> Test distr -> Bool
    $cmax :: forall distr. Ord distr => Test distr -> Test distr -> Test distr
    max :: Test distr -> Test distr -> Test distr
    $cmin :: forall distr. Ord distr => Test distr -> Test distr -> Test distr
    min :: Test distr -> Test distr -> Test distr
    Ord,Int -> Test distr -> ShowS
    [Test distr] -> ShowS
    Test distr -> String
    (Int -> Test distr -> ShowS)
    -> (Test distr -> String)
    -> ([Test distr] -> ShowS)
    -> Show (Test distr)
    forall distr. Show distr => Int -> Test distr -> ShowS
    forall distr. Show distr => [Test distr] -> ShowS
    forall distr. Show distr => Test distr -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall distr. Show distr => Int -> Test distr -> ShowS
    showsPrec :: Int -> Test distr -> ShowS
    $cshow :: forall distr. Show distr => Test distr -> String
    show :: Test distr -> String
    $cshowList :: forall distr. Show distr => [Test distr] -> ShowS
    showList :: [Test distr] -> ShowS
    Show,Typeable,Typeable (Test distr)
    Typeable (Test distr) =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Test distr -> c (Test distr))
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c (Test distr))
    -> (Test distr -> Constr)
    -> (Test distr -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c (Test distr)))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c (Test distr)))
    -> ((forall b. Data b => b -> b) -> Test distr -> Test distr)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Test distr -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Test distr -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Test distr -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Test distr -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Test distr -> m (Test distr))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Test distr -> m (Test distr))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Test distr -> m (Test distr))
    -> Data (Test distr)
    Test distr -> Constr
    Test distr -> DataType
    (forall b. Data b => b -> b) -> Test distr -> Test distr
    forall distr. Data distr => Typeable (Test distr)
    forall distr. Data distr => Test distr -> Constr
    forall distr. Data distr => Test distr -> DataType
    forall distr.
    Data distr =>
    (forall b. Data b => b -> b) -> Test distr -> Test distr
    forall distr u.
    Data distr =>
    Int -> (forall d. Data d => d -> u) -> Test distr -> u
    forall distr u.
    Data distr =>
    (forall d. Data d => d -> u) -> Test distr -> [u]
    forall distr r r'.
    Data distr =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    forall distr r r'.
    Data distr =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    forall distr (m :: * -> *).
    (Data distr, Monad m) =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    forall distr (m :: * -> *).
    (Data distr, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    forall distr (c :: * -> *).
    Data distr =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Test distr)
    forall distr (c :: * -> *).
    Data distr =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Test distr -> c (Test distr)
    forall distr (t :: * -> *) (c :: * -> *).
    (Data distr, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Test distr))
    forall distr (t :: * -> * -> *) (c :: * -> *).
    (Data distr, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Test distr))
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Test distr -> u
    forall u. (forall d. Data d => d -> u) -> Test distr -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Test distr)
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Test distr -> c (Test distr)
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Test distr))
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Test distr))
    $cgfoldl :: forall distr (c :: * -> *).
    Data distr =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Test distr -> c (Test distr)
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Test distr -> c (Test distr)
    $cgunfold :: forall distr (c :: * -> *).
    Data distr =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Test distr)
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Test distr)
    $ctoConstr :: forall distr. Data distr => Test distr -> Constr
    toConstr :: Test distr -> Constr
    $cdataTypeOf :: forall distr. Data distr => Test distr -> DataType
    dataTypeOf :: Test distr -> DataType
    $cdataCast1 :: forall distr (t :: * -> *) (c :: * -> *).
    (Data distr, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Test distr))
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Test distr))
    $cdataCast2 :: forall distr (t :: * -> * -> *) (c :: * -> *).
    (Data distr, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Test distr))
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Test distr))
    $cgmapT :: forall distr.
    Data distr =>
    (forall b. Data b => b -> b) -> Test distr -> Test distr
    gmapT :: (forall b. Data b => b -> b) -> Test distr -> Test distr
    $cgmapQl :: forall distr r r'.
    Data distr =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    $cgmapQr :: forall distr r r'.
    Data distr =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Test distr -> r
    $cgmapQ :: forall distr u.
    Data distr =>
    (forall d. Data d => d -> u) -> Test distr -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Test distr -> [u]
    $cgmapQi :: forall distr u.
    Data distr =>
    Int -> (forall d. Data d => d -> u) -> Test distr -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Test distr -> u
    $cgmapM :: forall distr (m :: * -> *).
    (Data distr, Monad m) =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    $cgmapMp :: forall distr (m :: * -> *).
    (Data distr, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    $cgmapMo :: forall distr (m :: * -> *).
    (Data distr, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Test distr -> m (Test distr)
    Data,(forall x. Test distr -> Rep (Test distr) x)
    -> (forall x. Rep (Test distr) x -> Test distr)
    -> Generic (Test distr)
    forall x. Rep (Test distr) x -> Test distr
    forall x. Test distr -> Rep (Test distr) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall distr x. Rep (Test distr) x -> Test distr
    forall distr x. Test distr -> Rep (Test distr) x
    $cfrom :: forall distr x. Test distr -> Rep (Test distr) x
    from :: forall x. Test distr -> Rep (Test distr) x
    $cto :: forall distr x. Rep (Test distr) x -> Test distr
    to :: forall x. Rep (Test distr) x -> Test distr
    Generic,(forall a b. (a -> b) -> Test a -> Test b)
    -> (forall a b. a -> Test b -> Test a) -> Functor Test
    forall a b. a -> Test b -> Test a
    forall a b. (a -> b) -> Test a -> Test b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Test a -> Test b
    fmap :: forall a b. (a -> b) -> Test a -> Test b
    $c<$ :: forall a b. a -> Test b -> Test a
    <$ :: forall a b. a -> Test b -> Test a
    Functor)

    instance (Binary   d) => Binary   (Test d) where
      get :: Get (Test d)
    get = (PValue Double -> Double -> d -> Test d)
    -> Get (PValue Double) -> Get Double -> Get d -> Get (Test d)
    forall (m :: * -> *) a1 a2 a3 r.
    Monad m =>
    (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
    liftM3 PValue Double -> Double -> d -> Test d
    forall distr. PValue Double -> Double -> distr -> Test distr
    Test Get (PValue Double)
    forall t. Binary t => Get t
    get Get Double
    forall t. Binary t => Get t
    get Get d
    forall t. Binary t => Get t
    get
      put :: Test d -> Put
    put (Test PValue Double
    sign Double
    stat d
    distr) = PValue Double -> Put
    forall t. Binary t => t -> Put
    put PValue Double
    sign Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Double -> Put
    forall t. Binary t => t -> Put
    put Double
    stat Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> d -> Put
    forall t. Binary t => t -> Put
    put d
    distr
    instance (FromJSON d) => FromJSON (Test d)
    instance (ToJSON   d) => ToJSON   (Test d)
    instance (NFData   d) => NFData   (Test d) where
      rnf :: Test d -> ()
    rnf (Test PValue Double
    _ Double
    _ d
    a) = d -> ()
    forall a. NFData a => a -> ()
    rnf d
    a

    -- | Check whether test is significant for given p-value.
    isSignificant :: PValue Double -> Test d -> TestResult
    isSignificant :: forall d. PValue Double -> Test d -> TestResult
    isSignificant PValue Double
    p Test d
    t
      = Bool -> TestResult
    significant (Bool -> TestResult) -> Bool -> TestResult
    forall a b. (a -> b) -> a -> b
    $ PValue Double
    p PValue Double -> PValue Double -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Test d -> PValue Double
    forall distr. Test distr -> PValue Double
    testSignificance Test d
    t

    -- | Test type for test which compare positional (mean,median etc.)
    --   information of samples.
    data PositionTest
      = SamplesDiffer
        -- ^ Test whether samples differ in position. Null hypothesis is
        --   samples are not different
      | AGreater
        -- ^ Test if first sample (A) is larger than second (B). Null
        --   hypothesis is first sample is not larger than second.
      | BGreater
        -- ^ Test if second sample is larger than first.
      deriving (PositionTest -> PositionTest -> Bool
    (PositionTest -> PositionTest -> Bool)
    -> (PositionTest -> PositionTest -> Bool) -> Eq PositionTest
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PositionTest -> PositionTest -> Bool
    == :: PositionTest -> PositionTest -> Bool
    $c/= :: PositionTest -> PositionTest -> Bool
    /= :: PositionTest -> PositionTest -> Bool
    Eq,Eq PositionTest
    Eq PositionTest =>
    (PositionTest -> PositionTest -> Ordering)
    -> (PositionTest -> PositionTest -> Bool)
    -> (PositionTest -> PositionTest -> Bool)
    -> (PositionTest -> PositionTest -> Bool)
    -> (PositionTest -> PositionTest -> Bool)
    -> (PositionTest -> PositionTest -> PositionTest)
    -> (PositionTest -> PositionTest -> PositionTest)
    -> Ord PositionTest
    PositionTest -> PositionTest -> Bool
    PositionTest -> PositionTest -> Ordering
    PositionTest -> PositionTest -> PositionTest
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: PositionTest -> PositionTest -> Ordering
    compare :: PositionTest -> PositionTest -> Ordering
    $c< :: PositionTest -> PositionTest -> Bool
    < :: PositionTest -> PositionTest -> Bool
    $c<= :: PositionTest -> PositionTest -> Bool
    <= :: PositionTest -> PositionTest -> Bool
    $c> :: PositionTest -> PositionTest -> Bool
    > :: PositionTest -> PositionTest -> Bool
    $c>= :: PositionTest -> PositionTest -> Bool
    >= :: PositionTest -> PositionTest -> Bool
    $cmax :: PositionTest -> PositionTest -> PositionTest
    max :: PositionTest -> PositionTest -> PositionTest
    $cmin :: PositionTest -> PositionTest -> PositionTest
    min :: PositionTest -> PositionTest -> PositionTest
    Ord,Int -> PositionTest -> ShowS
    [PositionTest] -> ShowS
    PositionTest -> String
    (Int -> PositionTest -> ShowS)
    -> (PositionTest -> String)
    -> ([PositionTest] -> ShowS)
    -> Show PositionTest
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> PositionTest -> ShowS
    showsPrec :: Int -> PositionTest -> ShowS
    $cshow :: PositionTest -> String
    show :: PositionTest -> String
    $cshowList :: [PositionTest] -> ShowS
    showList :: [PositionTest] -> ShowS
    Show,Typeable,Typeable PositionTest
    Typeable PositionTest =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> PositionTest -> c PositionTest)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c PositionTest)
    -> (PositionTest -> Constr)
    -> (PositionTest -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c PositionTest))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c PositionTest))
    -> ((forall b. Data b => b -> b) -> PositionTest -> PositionTest)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> PositionTest -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> PositionTest -> r)
    -> (forall u. (forall d. Data d => d -> u) -> PositionTest -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> PositionTest -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest)
    -> Data PositionTest
    PositionTest -> Constr
    PositionTest -> DataType
    (forall b. Data b => b -> b) -> PositionTest -> PositionTest
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> PositionTest -> u
    forall u. (forall d. Data d => d -> u) -> PositionTest -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PositionTest -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PositionTest -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PositionTest
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> PositionTest -> c PositionTest
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PositionTest)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c PositionTest)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> PositionTest -> c PositionTest
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> PositionTest -> c PositionTest
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PositionTest
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PositionTest
    $ctoConstr :: PositionTest -> Constr
    toConstr :: PositionTest -> Constr
    $cdataTypeOf :: PositionTest -> DataType
    dataTypeOf :: PositionTest -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PositionTest)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PositionTest)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c PositionTest)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c PositionTest)
    $cgmapT :: (forall b. Data b => b -> b) -> PositionTest -> PositionTest
    gmapT :: (forall b. Data b => b -> b) -> PositionTest -> PositionTest
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PositionTest -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PositionTest -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PositionTest -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PositionTest -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> PositionTest -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> PositionTest -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PositionTest -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PositionTest -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PositionTest -> m PositionTest
    Data,(forall x. PositionTest -> Rep PositionTest x)
    -> (forall x. Rep PositionTest x -> PositionTest)
    -> Generic PositionTest
    forall x. Rep PositionTest x -> PositionTest
    forall x. PositionTest -> Rep PositionTest x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. PositionTest -> Rep PositionTest x
    from :: forall x. PositionTest -> Rep PositionTest x
    $cto :: forall x. Rep PositionTest x -> PositionTest
    to :: forall x. Rep PositionTest x -> PositionTest
    Generic)

    instance Binary   PositionTest where
      get :: Get PositionTest
    get = do
        i <- Get Int
    forall t. Binary t => Get t
    get
        case (i :: Int) of
          Int
    0 -> PositionTest -> Get PositionTest
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return PositionTest
    SamplesDiffer
          Int
    1 -> PositionTest -> Get PositionTest
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return PositionTest
    AGreater
          Int
    2 -> PositionTest -> Get PositionTest
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return PositionTest
    BGreater
          Int
    _ -> String -> Get PositionTest
    forall a. String -> Get a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail String
    "Invalid PositionTest"
      put :: PositionTest -> Put
    put PositionTest
    SamplesDiffer = Int -> Put
    forall t. Binary t => t -> Put
    put (Int
    0 :: Int)
      put PositionTest
    AGreater      = Int -> Put
    forall t. Binary t => t -> Put
    put (Int
    1 :: Int)
      put PositionTest
    BGreater      = Int -> Put
    forall t. Binary t => t -> Put
    put (Int
    2 :: Int)
    instance FromJSON PositionTest
    instance ToJSON   PositionTest
    instance NFData   PositionTest

    -- | significant if parameter is 'True', not significant otherwise
    significant :: Bool -> TestResult
    significant :: Bool -> TestResult
    significant Bool
    True  = TestResult
    Significant
    significant Bool
    False = TestResult
    NotSignificant