{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
module Data.Monoid.Statistics.Numeric (
CountG(..)
, Count
, asCount
, Mean
, asMean
, WMean
, asWMean
, MeanNaive(..)
, asMeanNaive
, MeanKBN(..)
, asMeanKBN
, WMeanNaive(..)
, asWMeanNaive
, WMeanKBN(..)
, asWMeanKBN
, Variance(..)
, asVariance
, Max(..)
, Min(..)
, MaxD(..)
, MinD(..)
, BinomAcc(..)
, asBinomAcc
, Weighted(..)
) where
import Control.Monad.Catch (MonadThrow(..))
import Data.Data (Typeable,Data)
import Data.Vector.Unboxed (Unbox)
import Data.Vector.Unboxed.Deriving (derivingUnbox)
import Numeric.Sum
import GHC.Generics (Generic)
import Data.Monoid.Statistics.Class
newtype CountG a = CountG { CountG a -> a
calcCountN :: a }
deriving (Int -> CountG a -> ShowS
[CountG a] -> ShowS
CountG a -> String
(Int -> CountG a -> ShowS)
-> (CountG a -> String) -> ([CountG a] -> ShowS) -> Show (CountG a)
forall a. Show a => Int -> CountG a -> ShowS
forall a. Show a => [CountG a] -> ShowS
forall a. Show a => CountG a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CountG a] -> ShowS
$cshowList :: forall a. Show a => [CountG a] -> ShowS
show :: CountG a -> String
$cshow :: forall a. Show a => CountG a -> String
showsPrec :: Int -> CountG a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> CountG a -> ShowS
Show,CountG a -> CountG a -> Bool
(CountG a -> CountG a -> Bool)
-> (CountG a -> CountG a -> Bool) -> Eq (CountG a)
forall a. Eq a => CountG a -> CountG a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CountG a -> CountG a -> Bool
$c/= :: forall a. Eq a => CountG a -> CountG a -> Bool
== :: CountG a -> CountG a -> Bool
$c== :: forall a. Eq a => CountG a -> CountG a -> Bool
Eq,Eq (CountG a)
Eq (CountG a)
-> (CountG a -> CountG a -> Ordering)
-> (CountG a -> CountG a -> Bool)
-> (CountG a -> CountG a -> Bool)
-> (CountG a -> CountG a -> Bool)
-> (CountG a -> CountG a -> Bool)
-> (CountG a -> CountG a -> CountG a)
-> (CountG a -> CountG a -> CountG a)
-> Ord (CountG a)
CountG a -> CountG a -> Bool
CountG a -> CountG a -> Ordering
CountG a -> CountG a -> CountG a
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 a. Ord a => Eq (CountG a)
forall a. Ord a => CountG a -> CountG a -> Bool
forall a. Ord a => CountG a -> CountG a -> Ordering
forall a. Ord a => CountG a -> CountG a -> CountG a
min :: CountG a -> CountG a -> CountG a
$cmin :: forall a. Ord a => CountG a -> CountG a -> CountG a
max :: CountG a -> CountG a -> CountG a
$cmax :: forall a. Ord a => CountG a -> CountG a -> CountG a
>= :: CountG a -> CountG a -> Bool
$c>= :: forall a. Ord a => CountG a -> CountG a -> Bool
> :: CountG a -> CountG a -> Bool
$c> :: forall a. Ord a => CountG a -> CountG a -> Bool
<= :: CountG a -> CountG a -> Bool
$c<= :: forall a. Ord a => CountG a -> CountG a -> Bool
< :: CountG a -> CountG a -> Bool
$c< :: forall a. Ord a => CountG a -> CountG a -> Bool
compare :: CountG a -> CountG a -> Ordering
$ccompare :: forall a. Ord a => CountG a -> CountG a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (CountG a)
Ord,Typeable)
type Count = CountG Int
asCount :: CountG a -> CountG a
asCount :: CountG a -> CountG a
asCount = CountG a -> CountG a
forall a. a -> a
id
instance Integral a => Semigroup (CountG a) where
CountG a
i <> :: CountG a -> CountG a -> CountG a
<> CountG a
j = a -> CountG a
forall a. a -> CountG a
CountG (a
i a -> a -> a
forall a. Num a => a -> a -> a
+ a
j)
instance Integral a => Monoid (CountG a) where
mempty :: CountG a
mempty = a -> CountG a
forall a. a -> CountG a
CountG a
0
mappend :: CountG a -> CountG a -> CountG a
mappend = CountG a -> CountG a -> CountG a
forall a. Semigroup a => a -> a -> a
(<>)
instance (Integral a) => StatMonoid (CountG a) b where
singletonMonoid :: b -> CountG a
singletonMonoid b
_ = a -> CountG a
forall a. a -> CountG a
CountG a
1
addValue :: CountG a -> b -> CountG a
addValue (CountG a
n) b
_ = a -> CountG a
forall a. a -> CountG a
CountG (a
n a -> a -> a
forall a. Num a => a -> a -> a
+ a
1)
instance CalcCount (CountG Int) where
calcCount :: CountG Int -> Int
calcCount = CountG Int -> Int
forall a. CountG a -> a
calcCountN
type Mean = MeanKBN
asMean :: Mean -> Mean
asMean :: Mean -> Mean
asMean = Mean -> Mean
forall a. a -> a
id
type WMean = WMeanKBN
asWMean :: WMean -> WMean
asWMean :: WMean -> WMean
asWMean = WMean -> WMean
forall a. a -> a
id
data MeanNaive = MeanNaive !Int !Double
deriving (Int -> MeanNaive -> ShowS
[MeanNaive] -> ShowS
MeanNaive -> String
(Int -> MeanNaive -> ShowS)
-> (MeanNaive -> String)
-> ([MeanNaive] -> ShowS)
-> Show MeanNaive
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MeanNaive] -> ShowS
$cshowList :: [MeanNaive] -> ShowS
show :: MeanNaive -> String
$cshow :: MeanNaive -> String
showsPrec :: Int -> MeanNaive -> ShowS
$cshowsPrec :: Int -> MeanNaive -> ShowS
Show,MeanNaive -> MeanNaive -> Bool
(MeanNaive -> MeanNaive -> Bool)
-> (MeanNaive -> MeanNaive -> Bool) -> Eq MeanNaive
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MeanNaive -> MeanNaive -> Bool
$c/= :: MeanNaive -> MeanNaive -> Bool
== :: MeanNaive -> MeanNaive -> Bool
$c== :: MeanNaive -> MeanNaive -> Bool
Eq,Typeable,Typeable MeanNaive
DataType
Constr
Typeable MeanNaive
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeanNaive -> c MeanNaive)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeanNaive)
-> (MeanNaive -> Constr)
-> (MeanNaive -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeanNaive))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MeanNaive))
-> ((forall b. Data b => b -> b) -> MeanNaive -> MeanNaive)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r)
-> (forall u. (forall d. Data d => d -> u) -> MeanNaive -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> MeanNaive -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive)
-> Data MeanNaive
MeanNaive -> DataType
MeanNaive -> Constr
(forall b. Data b => b -> b) -> MeanNaive -> MeanNaive
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeanNaive -> c MeanNaive
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeanNaive
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) -> MeanNaive -> u
forall u. (forall d. Data d => d -> u) -> MeanNaive -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeanNaive
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeanNaive -> c MeanNaive
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeanNaive)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MeanNaive)
$cMeanNaive :: Constr
$tMeanNaive :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
gmapMp :: (forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
gmapM :: (forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MeanNaive -> m MeanNaive
gmapQi :: Int -> (forall d. Data d => d -> u) -> MeanNaive -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MeanNaive -> u
gmapQ :: (forall d. Data d => d -> u) -> MeanNaive -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MeanNaive -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MeanNaive -> r
gmapT :: (forall b. Data b => b -> b) -> MeanNaive -> MeanNaive
$cgmapT :: (forall b. Data b => b -> b) -> MeanNaive -> MeanNaive
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MeanNaive)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MeanNaive)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c MeanNaive)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MeanNaive)
dataTypeOf :: MeanNaive -> DataType
$cdataTypeOf :: MeanNaive -> DataType
toConstr :: MeanNaive -> Constr
$ctoConstr :: MeanNaive -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeanNaive
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MeanNaive
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeanNaive -> c MeanNaive
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MeanNaive -> c MeanNaive
$cp1Data :: Typeable MeanNaive
Data,(forall x. MeanNaive -> Rep MeanNaive x)
-> (forall x. Rep MeanNaive x -> MeanNaive) -> Generic MeanNaive
forall x. Rep MeanNaive x -> MeanNaive
forall x. MeanNaive -> Rep MeanNaive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MeanNaive x -> MeanNaive
$cfrom :: forall x. MeanNaive -> Rep MeanNaive x
Generic)
asMeanNaive :: MeanNaive -> MeanNaive
asMeanNaive :: MeanNaive -> MeanNaive
asMeanNaive = MeanNaive -> MeanNaive
forall a. a -> a
id
instance Semigroup MeanNaive where
MeanNaive Int
0 Double
_ <> :: MeanNaive -> MeanNaive -> MeanNaive
<> MeanNaive
m = MeanNaive
m
MeanNaive
m <> MeanNaive Int
0 Double
_ = MeanNaive
m
MeanNaive Int
n1 Double
s1 <> MeanNaive Int
n2 Double
s2 = Int -> Double -> MeanNaive
MeanNaive (Int
n1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
n2) (Double
s1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
s2)
instance Monoid MeanNaive where
mempty :: MeanNaive
mempty = Int -> Double -> MeanNaive
MeanNaive Int
0 Double
0
mappend :: MeanNaive -> MeanNaive -> MeanNaive
mappend = MeanNaive -> MeanNaive -> MeanNaive
forall a. Semigroup a => a -> a -> a
(<>)
instance Real a => StatMonoid MeanNaive a where
addValue :: MeanNaive -> a -> MeanNaive
addValue (MeanNaive Int
n Double
m) a
x = Int -> Double -> MeanNaive
MeanNaive (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) (Double
m Double -> Double -> Double
forall a. Num a => a -> a -> a
+ a -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac a
x)
{-# INLINE addValue #-}
instance CalcCount MeanNaive where
calcCount :: MeanNaive -> Int
calcCount (MeanNaive Int
n Double
_) = Int
n
instance CalcMean MeanNaive where
calcMean :: MeanNaive -> m Double
calcMean (MeanNaive Int
0 Double
_) = SampleError -> m Double
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (SampleError -> m Double) -> SampleError -> m Double
forall a b. (a -> b) -> a -> b
$ String -> SampleError
EmptySample String
"Data.Monoid.Statistics.Numeric.MeanNaive: calcMean"
calcMean (MeanNaive Int
n Double
s) = Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
s Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)
data MeanKBN = MeanKBN !Int {-# UNPACK #-} !KBNSum
deriving (Int -> Mean -> ShowS
[Mean] -> ShowS
Mean -> String
(Int -> Mean -> ShowS)
-> (Mean -> String) -> ([Mean] -> ShowS) -> Show Mean
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Mean] -> ShowS
$cshowList :: [Mean] -> ShowS
show :: Mean -> String
$cshow :: Mean -> String
showsPrec :: Int -> Mean -> ShowS
$cshowsPrec :: Int -> Mean -> ShowS
Show,Mean -> Mean -> Bool
(Mean -> Mean -> Bool) -> (Mean -> Mean -> Bool) -> Eq Mean
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Mean -> Mean -> Bool
$c/= :: Mean -> Mean -> Bool
== :: Mean -> Mean -> Bool
$c== :: Mean -> Mean -> Bool
Eq,Typeable,Typeable Mean
DataType
Constr
Typeable Mean
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Mean -> c Mean)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Mean)
-> (Mean -> Constr)
-> (Mean -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Mean))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Mean))
-> ((forall b. Data b => b -> b) -> Mean -> Mean)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r)
-> (forall u. (forall d. Data d => d -> u) -> Mean -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Mean -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean)
-> Data Mean
Mean -> DataType
Mean -> Constr
(forall b. Data b => b -> b) -> Mean -> Mean
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Mean -> c Mean
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Mean
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) -> Mean -> u
forall u. (forall d. Data d => d -> u) -> Mean -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Mean
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Mean -> c Mean
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Mean)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Mean)
$cMeanKBN :: Constr
$tMeanKBN :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Mean -> m Mean
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean
gmapMp :: (forall d. Data d => d -> m d) -> Mean -> m Mean
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean
gmapM :: (forall d. Data d => d -> m d) -> Mean -> m Mean
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Mean -> m Mean
gmapQi :: Int -> (forall d. Data d => d -> u) -> Mean -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Mean -> u
gmapQ :: (forall d. Data d => d -> u) -> Mean -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Mean -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Mean -> r
gmapT :: (forall b. Data b => b -> b) -> Mean -> Mean
$cgmapT :: (forall b. Data b => b -> b) -> Mean -> Mean
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Mean)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Mean)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Mean)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Mean)
dataTypeOf :: Mean -> DataType
$cdataTypeOf :: Mean -> DataType
toConstr :: Mean -> Constr
$ctoConstr :: Mean -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Mean
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Mean
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Mean -> c Mean
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Mean -> c Mean
$cp1Data :: Typeable Mean
Data,(forall x. Mean -> Rep Mean x)
-> (forall x. Rep Mean x -> Mean) -> Generic Mean
forall x. Rep Mean x -> Mean
forall x. Mean -> Rep Mean x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Mean x -> Mean
$cfrom :: forall x. Mean -> Rep Mean x
Generic)
asMeanKBN :: MeanKBN -> MeanKBN
asMeanKBN :: Mean -> Mean
asMeanKBN = Mean -> Mean
forall a. a -> a
id
instance Semigroup MeanKBN where
MeanKBN Int
0 KBNSum
_ <> :: Mean -> Mean -> Mean
<> Mean
m = Mean
m
Mean
m <> MeanKBN Int
0 KBNSum
_ = Mean
m
MeanKBN Int
n1 KBNSum
s1 <> MeanKBN Int
n2 KBNSum
s2 = Int -> KBNSum -> Mean
MeanKBN (Int
n1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
n2) (KBNSum
s1 KBNSum -> KBNSum -> KBNSum
forall a. Semigroup a => a -> a -> a
<> KBNSum
s2)
instance Monoid MeanKBN where
mempty :: Mean
mempty = Int -> KBNSum -> Mean
MeanKBN Int
0 KBNSum
forall a. Monoid a => a
mempty
mappend :: Mean -> Mean -> Mean
mappend = Mean -> Mean -> Mean
forall a. Semigroup a => a -> a -> a
(<>)
instance Real a => StatMonoid MeanKBN a where
addValue :: Mean -> a -> Mean
addValue (MeanKBN Int
n KBNSum
m) a
x = Int -> KBNSum -> Mean
MeanKBN (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) (KBNSum -> a -> KBNSum
forall m a. StatMonoid m a => m -> a -> m
addValue KBNSum
m a
x)
{-# INLINE addValue #-}
instance CalcCount MeanKBN where
calcCount :: Mean -> Int
calcCount (MeanKBN Int
n KBNSum
_) = Int
n
instance CalcMean MeanKBN where
calcMean :: Mean -> m Double
calcMean (MeanKBN Int
0 KBNSum
_) = SampleError -> m Double
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (SampleError -> m Double) -> SampleError -> m Double
forall a b. (a -> b) -> a -> b
$ String -> SampleError
EmptySample String
"Data.Monoid.Statistics.Numeric.MeanKBN: calcMean"
calcMean (MeanKBN Int
n KBNSum
s) = Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (KBNSum -> Double
kbn KBNSum
s Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)
data WMeanNaive = WMeanNaive
!Double
!Double
deriving (Int -> WMeanNaive -> ShowS
[WMeanNaive] -> ShowS
WMeanNaive -> String
(Int -> WMeanNaive -> ShowS)
-> (WMeanNaive -> String)
-> ([WMeanNaive] -> ShowS)
-> Show WMeanNaive
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WMeanNaive] -> ShowS
$cshowList :: [WMeanNaive] -> ShowS
show :: WMeanNaive -> String
$cshow :: WMeanNaive -> String
showsPrec :: Int -> WMeanNaive -> ShowS
$cshowsPrec :: Int -> WMeanNaive -> ShowS
Show,WMeanNaive -> WMeanNaive -> Bool
(WMeanNaive -> WMeanNaive -> Bool)
-> (WMeanNaive -> WMeanNaive -> Bool) -> Eq WMeanNaive
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WMeanNaive -> WMeanNaive -> Bool
$c/= :: WMeanNaive -> WMeanNaive -> Bool
== :: WMeanNaive -> WMeanNaive -> Bool
$c== :: WMeanNaive -> WMeanNaive -> Bool
Eq,Typeable,Typeable WMeanNaive
DataType
Constr
Typeable WMeanNaive
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMeanNaive -> c WMeanNaive)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMeanNaive)
-> (WMeanNaive -> Constr)
-> (WMeanNaive -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WMeanNaive))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c WMeanNaive))
-> ((forall b. Data b => b -> b) -> WMeanNaive -> WMeanNaive)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r)
-> (forall u. (forall d. Data d => d -> u) -> WMeanNaive -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> WMeanNaive -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive)
-> Data WMeanNaive
WMeanNaive -> DataType
WMeanNaive -> Constr
(forall b. Data b => b -> b) -> WMeanNaive -> WMeanNaive
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMeanNaive -> c WMeanNaive
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMeanNaive
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) -> WMeanNaive -> u
forall u. (forall d. Data d => d -> u) -> WMeanNaive -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMeanNaive
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMeanNaive -> c WMeanNaive
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WMeanNaive)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WMeanNaive)
$cWMeanNaive :: Constr
$tWMeanNaive :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
gmapMp :: (forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
gmapM :: (forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WMeanNaive -> m WMeanNaive
gmapQi :: Int -> (forall d. Data d => d -> u) -> WMeanNaive -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> WMeanNaive -> u
gmapQ :: (forall d. Data d => d -> u) -> WMeanNaive -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> WMeanNaive -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WMeanNaive -> r
gmapT :: (forall b. Data b => b -> b) -> WMeanNaive -> WMeanNaive
$cgmapT :: (forall b. Data b => b -> b) -> WMeanNaive -> WMeanNaive
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WMeanNaive)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WMeanNaive)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c WMeanNaive)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WMeanNaive)
dataTypeOf :: WMeanNaive -> DataType
$cdataTypeOf :: WMeanNaive -> DataType
toConstr :: WMeanNaive -> Constr
$ctoConstr :: WMeanNaive -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMeanNaive
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMeanNaive
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMeanNaive -> c WMeanNaive
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMeanNaive -> c WMeanNaive
$cp1Data :: Typeable WMeanNaive
Data,(forall x. WMeanNaive -> Rep WMeanNaive x)
-> (forall x. Rep WMeanNaive x -> WMeanNaive) -> Generic WMeanNaive
forall x. Rep WMeanNaive x -> WMeanNaive
forall x. WMeanNaive -> Rep WMeanNaive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WMeanNaive x -> WMeanNaive
$cfrom :: forall x. WMeanNaive -> Rep WMeanNaive x
Generic)
asWMeanNaive :: WMeanNaive -> WMeanNaive
asWMeanNaive :: WMeanNaive -> WMeanNaive
asWMeanNaive = WMeanNaive -> WMeanNaive
forall a. a -> a
id
instance Semigroup WMeanNaive where
WMeanNaive Double
w1 Double
s1 <> :: WMeanNaive -> WMeanNaive -> WMeanNaive
<> WMeanNaive Double
w2 Double
s2 = Double -> Double -> WMeanNaive
WMeanNaive (Double
w1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
w2) (Double
s1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
s2)
instance Monoid WMeanNaive where
mempty :: WMeanNaive
mempty = Double -> Double -> WMeanNaive
WMeanNaive Double
0 Double
0
mappend :: WMeanNaive -> WMeanNaive -> WMeanNaive
mappend = WMeanNaive -> WMeanNaive -> WMeanNaive
forall a. Semigroup a => a -> a -> a
(<>)
instance (Real w, Real a) => StatMonoid WMeanNaive (Weighted w a) where
addValue :: WMeanNaive -> Weighted w a -> WMeanNaive
addValue (WMeanNaive Double
n Double
s) (Weighted w
w a
a)
= Double -> Double -> WMeanNaive
WMeanNaive (Double
n Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
w') (Double
s Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double
w' Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
a'))
where
w' :: Double
w' = w -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac w
w
a' :: Double
a' = a -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac a
a
{-# INLINE addValue #-}
instance CalcMean WMeanNaive where
calcMean :: WMeanNaive -> m Double
calcMean (WMeanNaive Double
w Double
s)
| Double
w Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Double
0 = SampleError -> m Double
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (SampleError -> m Double) -> SampleError -> m Double
forall a b. (a -> b) -> a -> b
$ String -> SampleError
EmptySample String
"Data.Monoid.Statistics.Numeric.WMeanNaive: calcMean"
| Bool
otherwise = Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
s Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
w)
data WMeanKBN = WMeanKBN
{-# UNPACK #-} !KBNSum
{-# UNPACK #-} !KBNSum
deriving (Int -> WMean -> ShowS
[WMean] -> ShowS
WMean -> String
(Int -> WMean -> ShowS)
-> (WMean -> String) -> ([WMean] -> ShowS) -> Show WMean
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WMean] -> ShowS
$cshowList :: [WMean] -> ShowS
show :: WMean -> String
$cshow :: WMean -> String
showsPrec :: Int -> WMean -> ShowS
$cshowsPrec :: Int -> WMean -> ShowS
Show,WMean -> WMean -> Bool
(WMean -> WMean -> Bool) -> (WMean -> WMean -> Bool) -> Eq WMean
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WMean -> WMean -> Bool
$c/= :: WMean -> WMean -> Bool
== :: WMean -> WMean -> Bool
$c== :: WMean -> WMean -> Bool
Eq,Typeable,Typeable WMean
DataType
Constr
Typeable WMean
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMean -> c WMean)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMean)
-> (WMean -> Constr)
-> (WMean -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WMean))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WMean))
-> ((forall b. Data b => b -> b) -> WMean -> WMean)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r)
-> (forall u. (forall d. Data d => d -> u) -> WMean -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> WMean -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean)
-> Data WMean
WMean -> DataType
WMean -> Constr
(forall b. Data b => b -> b) -> WMean -> WMean
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMean -> c WMean
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMean
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) -> WMean -> u
forall u. (forall d. Data d => d -> u) -> WMean -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMean
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMean -> c WMean
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WMean)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WMean)
$cWMeanKBN :: Constr
$tWMeanKBN :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> WMean -> m WMean
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean
gmapMp :: (forall d. Data d => d -> m d) -> WMean -> m WMean
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean
gmapM :: (forall d. Data d => d -> m d) -> WMean -> m WMean
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WMean -> m WMean
gmapQi :: Int -> (forall d. Data d => d -> u) -> WMean -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> WMean -> u
gmapQ :: (forall d. Data d => d -> u) -> WMean -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> WMean -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WMean -> r
gmapT :: (forall b. Data b => b -> b) -> WMean -> WMean
$cgmapT :: (forall b. Data b => b -> b) -> WMean -> WMean
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WMean)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WMean)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c WMean)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WMean)
dataTypeOf :: WMean -> DataType
$cdataTypeOf :: WMean -> DataType
toConstr :: WMean -> Constr
$ctoConstr :: WMean -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMean
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WMean
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMean -> c WMean
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WMean -> c WMean
$cp1Data :: Typeable WMean
Data,(forall x. WMean -> Rep WMean x)
-> (forall x. Rep WMean x -> WMean) -> Generic WMean
forall x. Rep WMean x -> WMean
forall x. WMean -> Rep WMean x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WMean x -> WMean
$cfrom :: forall x. WMean -> Rep WMean x
Generic)
asWMeanKBN :: WMeanKBN -> WMeanKBN
asWMeanKBN :: WMean -> WMean
asWMeanKBN = WMean -> WMean
forall a. a -> a
id
instance Semigroup WMeanKBN where
WMeanKBN KBNSum
n1 KBNSum
s1 <> :: WMean -> WMean -> WMean
<> WMeanKBN KBNSum
n2 KBNSum
s2 = KBNSum -> KBNSum -> WMean
WMeanKBN (KBNSum
n1 KBNSum -> KBNSum -> KBNSum
forall a. Semigroup a => a -> a -> a
<> KBNSum
n2) (KBNSum
s1 KBNSum -> KBNSum -> KBNSum
forall a. Semigroup a => a -> a -> a
<> KBNSum
s2)
instance Monoid WMeanKBN where
mempty :: WMean
mempty = KBNSum -> KBNSum -> WMean
WMeanKBN KBNSum
forall a. Monoid a => a
mempty KBNSum
forall a. Monoid a => a
mempty
mappend :: WMean -> WMean -> WMean
mappend = WMean -> WMean -> WMean
forall a. Semigroup a => a -> a -> a
(<>)
instance (Real w, Real a) => StatMonoid WMeanKBN (Weighted w a) where
addValue :: WMean -> Weighted w a -> WMean
addValue (WMeanKBN KBNSum
n KBNSum
m) (Weighted w
w a
a)
= KBNSum -> KBNSum -> WMean
WMeanKBN (KBNSum -> Double -> KBNSum
forall s. Summation s => s -> Double -> s
add KBNSum
n Double
w') (KBNSum -> Double -> KBNSum
forall s. Summation s => s -> Double -> s
add KBNSum
m (Double
w' Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
a'))
where
w' :: Double
w' = w -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac w
w :: Double
a' :: Double
a' = a -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac a
a :: Double
{-# INLINE addValue #-}
instance CalcMean WMeanKBN where
calcMean :: WMean -> m Double
calcMean (WMeanKBN (KBNSum -> Double
kbn -> Double
w) (KBNSum -> Double
kbn -> Double
s))
| Double
w Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Double
0 = SampleError -> m Double
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (SampleError -> m Double) -> SampleError -> m Double
forall a b. (a -> b) -> a -> b
$ String -> SampleError
EmptySample String
"Data.Monoid.Statistics.Numeric.WMeanKBN: calcMean"
| Bool
otherwise = Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
s Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
w)
data VarWelfordKBN = VarWelfordKBN
{-# UNPACK #-} !Int
{-# UNPACK #-} !KBNSum
{-# UNPACK #-} !KBNSum
asVarWelfordKBN :: VarWelfordKBN -> VarWelfordKBN
asVarWelfordKBN :: VarWelfordKBN -> VarWelfordKBN
asVarWelfordKBN = VarWelfordKBN -> VarWelfordKBN
forall a. a -> a
id
data Variance = Variance {-# UNPACK #-} !Int
{-# UNPACK #-} !Double
{-# UNPACK #-} !Double
deriving (Int -> Variance -> ShowS
[Variance] -> ShowS
Variance -> String
(Int -> Variance -> ShowS)
-> (Variance -> String) -> ([Variance] -> ShowS) -> Show Variance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Variance] -> ShowS
$cshowList :: [Variance] -> ShowS
show :: Variance -> String
$cshow :: Variance -> String
showsPrec :: Int -> Variance -> ShowS
$cshowsPrec :: Int -> Variance -> ShowS
Show,Variance -> Variance -> Bool
(Variance -> Variance -> Bool)
-> (Variance -> Variance -> Bool) -> Eq Variance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Variance -> Variance -> Bool
$c/= :: Variance -> Variance -> Bool
== :: Variance -> Variance -> Bool
$c== :: Variance -> Variance -> Bool
Eq,Typeable)
asVariance :: Variance -> Variance
asVariance :: Variance -> Variance
asVariance = Variance -> Variance
forall a. a -> a
id
instance Semigroup Variance where
Variance Int
n1 Double
ta Double
sa <> :: Variance -> Variance -> Variance
<> Variance Int
n2 Double
tb Double
sb
= Int -> Double -> Double -> Variance
Variance (Int
n1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
n2) (Double
taDouble -> Double -> Double
forall a. Num a => a -> a -> a
+Double
tb) Double
sumsq
where
na :: Double
na = Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n1
nb :: Double
nb = Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n2
nom :: Double
nom = Double -> Double
sqr (Double
ta Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
nb Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
tb Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
na)
sumsq :: Double
sumsq | Int
n1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = Double
sb
| Int
n2 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = Double
sa
| Bool
otherwise = Double
sa Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
sb Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
nom Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ ((Double
na Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
nb) Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
na Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
nb)
instance Monoid Variance where
mempty :: Variance
mempty = Int -> Double -> Double -> Variance
Variance Int
0 Double
0 Double
0
mappend :: Variance -> Variance -> Variance
mappend = Variance -> Variance -> Variance
forall a. Semigroup a => a -> a -> a
(<>)
instance Real a => StatMonoid Variance a where
addValue :: Variance -> a -> Variance
addValue (Variance Int
0 Double
_ Double
_) a
x = a -> Variance
forall m a. StatMonoid m a => a -> m
singletonMonoid a
x
addValue (Variance Int
n Double
t Double
s) (a -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac -> Double
x)
= Int -> Double -> Double -> Variance
Variance (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x) (Double
s Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double -> Double
sqr (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
n' Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
x) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
n' Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
n'Double -> Double -> Double
forall a. Num a => a -> a -> a
+Double
1)))
where
n' :: Double
n' = Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n
{-# INLINE addValue #-}
singletonMonoid :: a -> Variance
singletonMonoid a
x = Int -> Double -> Double -> Variance
Variance Int
1 (a -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac a
x) Double
0
{-# INLINE singletonMonoid #-}
instance CalcCount Variance where
calcCount :: Variance -> Int
calcCount (Variance Int
n Double
_ Double
_) = Int
n
instance CalcMean Variance where
calcMean :: Variance -> m Double
calcMean (Variance Int
0 Double
_ Double
_) = SampleError -> m Double
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (SampleError -> m Double) -> SampleError -> m Double
forall a b. (a -> b) -> a -> b
$ String -> SampleError
EmptySample String
"Data.Monoid.Statistics.Numeric.Variance: calcMean"
calcMean (Variance Int
n Double
s Double
_) = Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
s Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)
instance CalcVariance Variance where
calcVariance :: Variance -> m Double
calcVariance (Variance Int
n Double
_ Double
s)
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
2 = SampleError -> m Double
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (SampleError -> m Double) -> SampleError -> m Double
forall a b. (a -> b) -> a -> b
$ String -> String -> SampleError
InvalidSample
String
"Data.Monoid.Statistics.Numeric.Variance: calcVariance"
String
"Need at least 2 elements"
| Bool
otherwise = Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double -> m Double) -> Double -> m Double
forall a b. (a -> b) -> a -> b
$! Double
s Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
calcVarianceML :: Variance -> m Double
calcVarianceML (Variance Int
n Double
_ Double
s)
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
1 = SampleError -> m Double
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (SampleError -> m Double) -> SampleError -> m Double
forall a b. (a -> b) -> a -> b
$ String -> String -> SampleError
InvalidSample
String
"Data.Monoid.Statistics.Numeric.Variance: calcVarianceML"
String
"Need at least 1 element"
| Bool
otherwise = Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double -> m Double) -> Double -> m Double
forall a b. (a -> b) -> a -> b
$! Double
s Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n
newtype Min a = Min { Min a -> Maybe a
calcMin :: Maybe a }
deriving (Int -> Min a -> ShowS
[Min a] -> ShowS
Min a -> String
(Int -> Min a -> ShowS)
-> (Min a -> String) -> ([Min a] -> ShowS) -> Show (Min a)
forall a. Show a => Int -> Min a -> ShowS
forall a. Show a => [Min a] -> ShowS
forall a. Show a => Min a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Min a] -> ShowS
$cshowList :: forall a. Show a => [Min a] -> ShowS
show :: Min a -> String
$cshow :: forall a. Show a => Min a -> String
showsPrec :: Int -> Min a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Min a -> ShowS
Show,Min a -> Min a -> Bool
(Min a -> Min a -> Bool) -> (Min a -> Min a -> Bool) -> Eq (Min a)
forall a. Eq a => Min a -> Min a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Min a -> Min a -> Bool
$c/= :: forall a. Eq a => Min a -> Min a -> Bool
== :: Min a -> Min a -> Bool
$c== :: forall a. Eq a => Min a -> Min a -> Bool
Eq,Eq (Min a)
Eq (Min a)
-> (Min a -> Min a -> Ordering)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Min a)
-> (Min a -> Min a -> Min a)
-> Ord (Min a)
Min a -> Min a -> Bool
Min a -> Min a -> Ordering
Min a -> Min a -> Min a
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 a. Ord a => Eq (Min a)
forall a. Ord a => Min a -> Min a -> Bool
forall a. Ord a => Min a -> Min a -> Ordering
forall a. Ord a => Min a -> Min a -> Min a
min :: Min a -> Min a -> Min a
$cmin :: forall a. Ord a => Min a -> Min a -> Min a
max :: Min a -> Min a -> Min a
$cmax :: forall a. Ord a => Min a -> Min a -> Min a
>= :: Min a -> Min a -> Bool
$c>= :: forall a. Ord a => Min a -> Min a -> Bool
> :: Min a -> Min a -> Bool
$c> :: forall a. Ord a => Min a -> Min a -> Bool
<= :: Min a -> Min a -> Bool
$c<= :: forall a. Ord a => Min a -> Min a -> Bool
< :: Min a -> Min a -> Bool
$c< :: forall a. Ord a => Min a -> Min a -> Bool
compare :: Min a -> Min a -> Ordering
$ccompare :: forall a. Ord a => Min a -> Min a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Min a)
Ord,Typeable,Typeable (Min a)
DataType
Constr
Typeable (Min a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a))
-> (Min a -> Constr)
-> (Min a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a)))
-> ((forall b. Data b => b -> b) -> Min a -> Min a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Min a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Min a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a))
-> Data (Min a)
Min a -> DataType
Min a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
(forall b. Data b => b -> b) -> Min a -> Min a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
forall a. Data a => Typeable (Min a)
forall a. Data a => Min a -> DataType
forall a. Data a => Min a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> Min a -> Min a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Min a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Min a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
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) -> Min a -> u
forall u. (forall d. Data d => d -> u) -> Min a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
$cMin :: Constr
$tMin :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Min a -> m (Min a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
gmapMp :: (forall d. Data d => d -> m d) -> Min a -> m (Min a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
gmapM :: (forall d. Data d => d -> m d) -> Min a -> m (Min a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Min a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Min a -> u
gmapQ :: (forall d. Data d => d -> u) -> Min a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Min a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
gmapT :: (forall b. Data b => b -> b) -> Min a -> Min a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> Min a -> Min a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Min a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
dataTypeOf :: Min a -> DataType
$cdataTypeOf :: forall a. Data a => Min a -> DataType
toConstr :: Min a -> Constr
$ctoConstr :: forall a. Data a => Min a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
$cp1Data :: forall a. Data a => Typeable (Min a)
Data,(forall x. Min a -> Rep (Min a) x)
-> (forall x. Rep (Min a) x -> Min a) -> Generic (Min a)
forall x. Rep (Min a) x -> Min a
forall x. Min a -> Rep (Min a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Min a) x -> Min a
forall a x. Min a -> Rep (Min a) x
$cto :: forall a x. Rep (Min a) x -> Min a
$cfrom :: forall a x. Min a -> Rep (Min a) x
Generic)
instance Ord a => Semigroup (Min a) where
Min (Just a
a) <> :: Min a -> Min a -> Min a
<> Min (Just a
b) = Maybe a -> Min a
forall a. Maybe a -> Min a
Min (a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a -> a -> a
forall a. Ord a => a -> a -> a
min a
a a
b)
Min Maybe a
a <> Min Maybe a
Nothing = Maybe a -> Min a
forall a. Maybe a -> Min a
Min Maybe a
a
Min Maybe a
Nothing <> Min Maybe a
b = Maybe a -> Min a
forall a. Maybe a -> Min a
Min Maybe a
b
instance Ord a => Monoid (Min a) where
mempty :: Min a
mempty = Maybe a -> Min a
forall a. Maybe a -> Min a
Min Maybe a
forall a. Maybe a
Nothing
mappend :: Min a -> Min a -> Min a
mappend = Min a -> Min a -> Min a
forall a. Semigroup a => a -> a -> a
(<>)
instance (Ord a, a ~ a') => StatMonoid (Min a) a' where
singletonMonoid :: a' -> Min a
singletonMonoid a'
a = Maybe a' -> Min a'
forall a. Maybe a -> Min a
Min (a' -> Maybe a'
forall a. a -> Maybe a
Just a'
a)
newtype Max a = Max { Max a -> Maybe a
calcMax :: Maybe a }
deriving (Int -> Max a -> ShowS
[Max a] -> ShowS
Max a -> String
(Int -> Max a -> ShowS)
-> (Max a -> String) -> ([Max a] -> ShowS) -> Show (Max a)
forall a. Show a => Int -> Max a -> ShowS
forall a. Show a => [Max a] -> ShowS
forall a. Show a => Max a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Max a] -> ShowS
$cshowList :: forall a. Show a => [Max a] -> ShowS
show :: Max a -> String
$cshow :: forall a. Show a => Max a -> String
showsPrec :: Int -> Max a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Max a -> ShowS
Show,Max a -> Max a -> Bool
(Max a -> Max a -> Bool) -> (Max a -> Max a -> Bool) -> Eq (Max a)
forall a. Eq a => Max a -> Max a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Max a -> Max a -> Bool
$c/= :: forall a. Eq a => Max a -> Max a -> Bool
== :: Max a -> Max a -> Bool
$c== :: forall a. Eq a => Max a -> Max a -> Bool
Eq,Eq (Max a)
Eq (Max a)
-> (Max a -> Max a -> Ordering)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Max a)
-> (Max a -> Max a -> Max a)
-> Ord (Max a)
Max a -> Max a -> Bool
Max a -> Max a -> Ordering
Max a -> Max a -> Max a
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 a. Ord a => Eq (Max a)
forall a. Ord a => Max a -> Max a -> Bool
forall a. Ord a => Max a -> Max a -> Ordering
forall a. Ord a => Max a -> Max a -> Max a
min :: Max a -> Max a -> Max a
$cmin :: forall a. Ord a => Max a -> Max a -> Max a
max :: Max a -> Max a -> Max a
$cmax :: forall a. Ord a => Max a -> Max a -> Max a
>= :: Max a -> Max a -> Bool
$c>= :: forall a. Ord a => Max a -> Max a -> Bool
> :: Max a -> Max a -> Bool
$c> :: forall a. Ord a => Max a -> Max a -> Bool
<= :: Max a -> Max a -> Bool
$c<= :: forall a. Ord a => Max a -> Max a -> Bool
< :: Max a -> Max a -> Bool
$c< :: forall a. Ord a => Max a -> Max a -> Bool
compare :: Max a -> Max a -> Ordering
$ccompare :: forall a. Ord a => Max a -> Max a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Max a)
Ord,Typeable,Typeable (Max a)
DataType
Constr
Typeable (Max a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a))
-> (Max a -> Constr)
-> (Max a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a)))
-> ((forall b. Data b => b -> b) -> Max a -> Max a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Max a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Max a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a))
-> Data (Max a)
Max a -> DataType
Max a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
(forall b. Data b => b -> b) -> Max a -> Max a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
forall a. Data a => Typeable (Max a)
forall a. Data a => Max a -> DataType
forall a. Data a => Max a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> Max a -> Max a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Max a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Max a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
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) -> Max a -> u
forall u. (forall d. Data d => d -> u) -> Max a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
$cMax :: Constr
$tMax :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Max a -> m (Max a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
gmapMp :: (forall d. Data d => d -> m d) -> Max a -> m (Max a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
gmapM :: (forall d. Data d => d -> m d) -> Max a -> m (Max a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Max a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Max a -> u
gmapQ :: (forall d. Data d => d -> u) -> Max a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Max a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
gmapT :: (forall b. Data b => b -> b) -> Max a -> Max a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> Max a -> Max a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Max a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
dataTypeOf :: Max a -> DataType
$cdataTypeOf :: forall a. Data a => Max a -> DataType
toConstr :: Max a -> Constr
$ctoConstr :: forall a. Data a => Max a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
$cp1Data :: forall a. Data a => Typeable (Max a)
Data,(forall x. Max a -> Rep (Max a) x)
-> (forall x. Rep (Max a) x -> Max a) -> Generic (Max a)
forall x. Rep (Max a) x -> Max a
forall x. Max a -> Rep (Max a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Max a) x -> Max a
forall a x. Max a -> Rep (Max a) x
$cto :: forall a x. Rep (Max a) x -> Max a
$cfrom :: forall a x. Max a -> Rep (Max a) x
Generic)
instance Ord a => Semigroup (Max a) where
Max (Just a
a) <> :: Max a -> Max a -> Max a
<> Max (Just a
b) = Maybe a -> Max a
forall a. Maybe a -> Max a
Max (a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$! a -> a -> a
forall a. Ord a => a -> a -> a
max a
a a
b)
Max Maybe a
a <> Max Maybe a
Nothing = Maybe a -> Max a
forall a. Maybe a -> Max a
Max Maybe a
a
Max Maybe a
Nothing <> Max Maybe a
b = Maybe a -> Max a
forall a. Maybe a -> Max a
Max Maybe a
b
instance Ord a => Monoid (Max a) where
mempty :: Max a
mempty = Maybe a -> Max a
forall a. Maybe a -> Max a
Max Maybe a
forall a. Maybe a
Nothing
mappend :: Max a -> Max a -> Max a
mappend = Max a -> Max a -> Max a
forall a. Semigroup a => a -> a -> a
(<>)
instance (Ord a, a ~ a') => StatMonoid (Max a) a' where
singletonMonoid :: a' -> Max a
singletonMonoid a'
a = Maybe a' -> Max a'
forall a. Maybe a -> Max a
Max (a' -> Maybe a'
forall a. a -> Maybe a
Just a'
a)
newtype MinD = MinD { MinD -> Double
calcMinD :: Double }
deriving (Int -> MinD -> ShowS
[MinD] -> ShowS
MinD -> String
(Int -> MinD -> ShowS)
-> (MinD -> String) -> ([MinD] -> ShowS) -> Show MinD
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MinD] -> ShowS
$cshowList :: [MinD] -> ShowS
show :: MinD -> String
$cshow :: MinD -> String
showsPrec :: Int -> MinD -> ShowS
$cshowsPrec :: Int -> MinD -> ShowS
Show,Typeable,Typeable MinD
DataType
Constr
Typeable MinD
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MinD -> c MinD)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MinD)
-> (MinD -> Constr)
-> (MinD -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MinD))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MinD))
-> ((forall b. Data b => b -> b) -> MinD -> MinD)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r)
-> (forall u. (forall d. Data d => d -> u) -> MinD -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> MinD -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD)
-> Data MinD
MinD -> DataType
MinD -> Constr
(forall b. Data b => b -> b) -> MinD -> MinD
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MinD -> c MinD
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MinD
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) -> MinD -> u
forall u. (forall d. Data d => d -> u) -> MinD -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MinD
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MinD -> c MinD
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MinD)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MinD)
$cMinD :: Constr
$tMinD :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> MinD -> m MinD
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD
gmapMp :: (forall d. Data d => d -> m d) -> MinD -> m MinD
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD
gmapM :: (forall d. Data d => d -> m d) -> MinD -> m MinD
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MinD -> m MinD
gmapQi :: Int -> (forall d. Data d => d -> u) -> MinD -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MinD -> u
gmapQ :: (forall d. Data d => d -> u) -> MinD -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MinD -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MinD -> r
gmapT :: (forall b. Data b => b -> b) -> MinD -> MinD
$cgmapT :: (forall b. Data b => b -> b) -> MinD -> MinD
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MinD)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MinD)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c MinD)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MinD)
dataTypeOf :: MinD -> DataType
$cdataTypeOf :: MinD -> DataType
toConstr :: MinD -> Constr
$ctoConstr :: MinD -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MinD
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MinD
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MinD -> c MinD
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MinD -> c MinD
$cp1Data :: Typeable MinD
Data,(forall x. MinD -> Rep MinD x)
-> (forall x. Rep MinD x -> MinD) -> Generic MinD
forall x. Rep MinD x -> MinD
forall x. MinD -> Rep MinD x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MinD x -> MinD
$cfrom :: forall x. MinD -> Rep MinD x
Generic)
instance Eq MinD where
MinD Double
a == :: MinD -> MinD -> Bool
== MinD Double
b
| Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
a Bool -> Bool -> Bool
&& Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
b = Bool
True
| Bool
otherwise = Double
a Double -> Double -> Bool
forall a. Eq a => a -> a -> Bool
== Double
b
instance Semigroup MinD where
MinD Double
x <> :: MinD -> MinD -> MinD
<> MinD Double
y
| Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
x = Double -> MinD
MinD Double
y
| Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
y = Double -> MinD
MinD Double
x
| Bool
otherwise = Double -> MinD
MinD (Double -> Double -> Double
forall a. Ord a => a -> a -> a
min Double
x Double
y)
instance Monoid MinD where
mempty :: MinD
mempty = Double -> MinD
MinD (Double
0Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
0)
mappend :: MinD -> MinD -> MinD
mappend = MinD -> MinD -> MinD
forall a. Semigroup a => a -> a -> a
(<>)
instance a ~ Double => StatMonoid MinD a where
singletonMonoid :: a -> MinD
singletonMonoid = a -> MinD
Double -> MinD
MinD
newtype MaxD = MaxD { MaxD -> Double
calcMaxD :: Double }
deriving (Int -> MaxD -> ShowS
[MaxD] -> ShowS
MaxD -> String
(Int -> MaxD -> ShowS)
-> (MaxD -> String) -> ([MaxD] -> ShowS) -> Show MaxD
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MaxD] -> ShowS
$cshowList :: [MaxD] -> ShowS
show :: MaxD -> String
$cshow :: MaxD -> String
showsPrec :: Int -> MaxD -> ShowS
$cshowsPrec :: Int -> MaxD -> ShowS
Show,Typeable,Typeable MaxD
DataType
Constr
Typeable MaxD
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaxD -> c MaxD)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MaxD)
-> (MaxD -> Constr)
-> (MaxD -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MaxD))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MaxD))
-> ((forall b. Data b => b -> b) -> MaxD -> MaxD)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r)
-> (forall u. (forall d. Data d => d -> u) -> MaxD -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> MaxD -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD)
-> Data MaxD
MaxD -> DataType
MaxD -> Constr
(forall b. Data b => b -> b) -> MaxD -> MaxD
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaxD -> c MaxD
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MaxD
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) -> MaxD -> u
forall u. (forall d. Data d => d -> u) -> MaxD -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MaxD
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaxD -> c MaxD
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MaxD)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MaxD)
$cMaxD :: Constr
$tMaxD :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> MaxD -> m MaxD
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD
gmapMp :: (forall d. Data d => d -> m d) -> MaxD -> m MaxD
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD
gmapM :: (forall d. Data d => d -> m d) -> MaxD -> m MaxD
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MaxD -> m MaxD
gmapQi :: Int -> (forall d. Data d => d -> u) -> MaxD -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MaxD -> u
gmapQ :: (forall d. Data d => d -> u) -> MaxD -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MaxD -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MaxD -> r
gmapT :: (forall b. Data b => b -> b) -> MaxD -> MaxD
$cgmapT :: (forall b. Data b => b -> b) -> MaxD -> MaxD
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MaxD)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MaxD)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c MaxD)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MaxD)
dataTypeOf :: MaxD -> DataType
$cdataTypeOf :: MaxD -> DataType
toConstr :: MaxD -> Constr
$ctoConstr :: MaxD -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MaxD
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MaxD
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaxD -> c MaxD
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaxD -> c MaxD
$cp1Data :: Typeable MaxD
Data,(forall x. MaxD -> Rep MaxD x)
-> (forall x. Rep MaxD x -> MaxD) -> Generic MaxD
forall x. Rep MaxD x -> MaxD
forall x. MaxD -> Rep MaxD x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MaxD x -> MaxD
$cfrom :: forall x. MaxD -> Rep MaxD x
Generic)
instance Eq MaxD where
MaxD Double
a == :: MaxD -> MaxD -> Bool
== MaxD Double
b
| Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
a Bool -> Bool -> Bool
&& Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
b = Bool
True
| Bool
otherwise = Double
a Double -> Double -> Bool
forall a. Eq a => a -> a -> Bool
== Double
b
instance Semigroup MaxD where
MaxD Double
x <> :: MaxD -> MaxD -> MaxD
<> MaxD Double
y
| Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
x = Double -> MaxD
MaxD Double
y
| Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
y = Double -> MaxD
MaxD Double
x
| Bool
otherwise = Double -> MaxD
MaxD (Double -> Double -> Double
forall a. Ord a => a -> a -> a
max Double
x Double
y)
instance Monoid MaxD where
mempty :: MaxD
mempty = Double -> MaxD
MaxD (Double
0Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
0)
mappend :: MaxD -> MaxD -> MaxD
mappend = MaxD -> MaxD -> MaxD
forall a. Semigroup a => a -> a -> a
(<>)
instance a ~ Double => StatMonoid MaxD a where
singletonMonoid :: a -> MaxD
singletonMonoid = a -> MaxD
Double -> MaxD
MaxD
data BinomAcc = BinomAcc { BinomAcc -> Int
binomAccSuccess :: !Int
, BinomAcc -> Int
binomAccTotal :: !Int
}
deriving (Int -> BinomAcc -> ShowS
[BinomAcc] -> ShowS
BinomAcc -> String
(Int -> BinomAcc -> ShowS)
-> (BinomAcc -> String) -> ([BinomAcc] -> ShowS) -> Show BinomAcc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BinomAcc] -> ShowS
$cshowList :: [BinomAcc] -> ShowS
show :: BinomAcc -> String
$cshow :: BinomAcc -> String
showsPrec :: Int -> BinomAcc -> ShowS
$cshowsPrec :: Int -> BinomAcc -> ShowS
Show,BinomAcc -> BinomAcc -> Bool
(BinomAcc -> BinomAcc -> Bool)
-> (BinomAcc -> BinomAcc -> Bool) -> Eq BinomAcc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BinomAcc -> BinomAcc -> Bool
$c/= :: BinomAcc -> BinomAcc -> Bool
== :: BinomAcc -> BinomAcc -> Bool
$c== :: BinomAcc -> BinomAcc -> Bool
Eq,Eq BinomAcc
Eq BinomAcc
-> (BinomAcc -> BinomAcc -> Ordering)
-> (BinomAcc -> BinomAcc -> Bool)
-> (BinomAcc -> BinomAcc -> Bool)
-> (BinomAcc -> BinomAcc -> Bool)
-> (BinomAcc -> BinomAcc -> Bool)
-> (BinomAcc -> BinomAcc -> BinomAcc)
-> (BinomAcc -> BinomAcc -> BinomAcc)
-> Ord BinomAcc
BinomAcc -> BinomAcc -> Bool
BinomAcc -> BinomAcc -> Ordering
BinomAcc -> BinomAcc -> BinomAcc
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
min :: BinomAcc -> BinomAcc -> BinomAcc
$cmin :: BinomAcc -> BinomAcc -> BinomAcc
max :: BinomAcc -> BinomAcc -> BinomAcc
$cmax :: BinomAcc -> BinomAcc -> BinomAcc
>= :: BinomAcc -> BinomAcc -> Bool
$c>= :: BinomAcc -> BinomAcc -> Bool
> :: BinomAcc -> BinomAcc -> Bool
$c> :: BinomAcc -> BinomAcc -> Bool
<= :: BinomAcc -> BinomAcc -> Bool
$c<= :: BinomAcc -> BinomAcc -> Bool
< :: BinomAcc -> BinomAcc -> Bool
$c< :: BinomAcc -> BinomAcc -> Bool
compare :: BinomAcc -> BinomAcc -> Ordering
$ccompare :: BinomAcc -> BinomAcc -> Ordering
$cp1Ord :: Eq BinomAcc
Ord,Typeable,Typeable BinomAcc
DataType
Constr
Typeable BinomAcc
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinomAcc -> c BinomAcc)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinomAcc)
-> (BinomAcc -> Constr)
-> (BinomAcc -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BinomAcc))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinomAcc))
-> ((forall b. Data b => b -> b) -> BinomAcc -> BinomAcc)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r)
-> (forall u. (forall d. Data d => d -> u) -> BinomAcc -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> BinomAcc -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc)
-> Data BinomAcc
BinomAcc -> DataType
BinomAcc -> Constr
(forall b. Data b => b -> b) -> BinomAcc -> BinomAcc
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinomAcc -> c BinomAcc
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinomAcc
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) -> BinomAcc -> u
forall u. (forall d. Data d => d -> u) -> BinomAcc -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinomAcc
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinomAcc -> c BinomAcc
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BinomAcc)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinomAcc)
$cBinomAcc :: Constr
$tBinomAcc :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
gmapMp :: (forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
gmapM :: (forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BinomAcc -> m BinomAcc
gmapQi :: Int -> (forall d. Data d => d -> u) -> BinomAcc -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BinomAcc -> u
gmapQ :: (forall d. Data d => d -> u) -> BinomAcc -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BinomAcc -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BinomAcc -> r
gmapT :: (forall b. Data b => b -> b) -> BinomAcc -> BinomAcc
$cgmapT :: (forall b. Data b => b -> b) -> BinomAcc -> BinomAcc
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinomAcc)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinomAcc)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BinomAcc)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BinomAcc)
dataTypeOf :: BinomAcc -> DataType
$cdataTypeOf :: BinomAcc -> DataType
toConstr :: BinomAcc -> Constr
$ctoConstr :: BinomAcc -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinomAcc
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinomAcc
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinomAcc -> c BinomAcc
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinomAcc -> c BinomAcc
$cp1Data :: Typeable BinomAcc
Data,(forall x. BinomAcc -> Rep BinomAcc x)
-> (forall x. Rep BinomAcc x -> BinomAcc) -> Generic BinomAcc
forall x. Rep BinomAcc x -> BinomAcc
forall x. BinomAcc -> Rep BinomAcc x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BinomAcc x -> BinomAcc
$cfrom :: forall x. BinomAcc -> Rep BinomAcc x
Generic)
asBinomAcc :: BinomAcc -> BinomAcc
asBinomAcc :: BinomAcc -> BinomAcc
asBinomAcc = BinomAcc -> BinomAcc
forall a. a -> a
id
instance Semigroup BinomAcc where
BinomAcc Int
n1 Int
m1 <> :: BinomAcc -> BinomAcc -> BinomAcc
<> BinomAcc Int
n2 Int
m2 = Int -> Int -> BinomAcc
BinomAcc (Int
n1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
n2) (Int
m1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
m2)
instance Monoid BinomAcc where
mempty :: BinomAcc
mempty = Int -> Int -> BinomAcc
BinomAcc Int
0 Int
0
mappend :: BinomAcc -> BinomAcc -> BinomAcc
mappend = BinomAcc -> BinomAcc -> BinomAcc
forall a. Semigroup a => a -> a -> a
(<>)
instance StatMonoid BinomAcc Bool where
addValue :: BinomAcc -> Bool -> BinomAcc
addValue (BinomAcc Int
nS Int
nT) Bool
True = Int -> Int -> BinomAcc
BinomAcc (Int
nSInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) (Int
nTInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
addValue (BinomAcc Int
nS Int
nT) Bool
False = Int -> Int -> BinomAcc
BinomAcc Int
nS (Int
nTInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
data Weighted w a = Weighted w a
deriving (Int -> Weighted w a -> ShowS
[Weighted w a] -> ShowS
Weighted w a -> String
(Int -> Weighted w a -> ShowS)
-> (Weighted w a -> String)
-> ([Weighted w a] -> ShowS)
-> Show (Weighted w a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall w a. (Show w, Show a) => Int -> Weighted w a -> ShowS
forall w a. (Show w, Show a) => [Weighted w a] -> ShowS
forall w a. (Show w, Show a) => Weighted w a -> String
showList :: [Weighted w a] -> ShowS
$cshowList :: forall w a. (Show w, Show a) => [Weighted w a] -> ShowS
show :: Weighted w a -> String
$cshow :: forall w a. (Show w, Show a) => Weighted w a -> String
showsPrec :: Int -> Weighted w a -> ShowS
$cshowsPrec :: forall w a. (Show w, Show a) => Int -> Weighted w a -> ShowS
Show,Weighted w a -> Weighted w a -> Bool
(Weighted w a -> Weighted w a -> Bool)
-> (Weighted w a -> Weighted w a -> Bool) -> Eq (Weighted w a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall w a. (Eq w, Eq a) => Weighted w a -> Weighted w a -> Bool
/= :: Weighted w a -> Weighted w a -> Bool
$c/= :: forall w a. (Eq w, Eq a) => Weighted w a -> Weighted w a -> Bool
== :: Weighted w a -> Weighted w a -> Bool
$c== :: forall w a. (Eq w, Eq a) => Weighted w a -> Weighted w a -> Bool
Eq,Eq (Weighted w a)
Eq (Weighted w a)
-> (Weighted w a -> Weighted w a -> Ordering)
-> (Weighted w a -> Weighted w a -> Bool)
-> (Weighted w a -> Weighted w a -> Bool)
-> (Weighted w a -> Weighted w a -> Bool)
-> (Weighted w a -> Weighted w a -> Bool)
-> (Weighted w a -> Weighted w a -> Weighted w a)
-> (Weighted w a -> Weighted w a -> Weighted w a)
-> Ord (Weighted w a)
Weighted w a -> Weighted w a -> Bool
Weighted w a -> Weighted w a -> Ordering
Weighted w a -> Weighted w a -> Weighted w a
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 w a. (Ord w, Ord a) => Eq (Weighted w a)
forall w a. (Ord w, Ord a) => Weighted w a -> Weighted w a -> Bool
forall w a.
(Ord w, Ord a) =>
Weighted w a -> Weighted w a -> Ordering
forall w a.
(Ord w, Ord a) =>
Weighted w a -> Weighted w a -> Weighted w a
min :: Weighted w a -> Weighted w a -> Weighted w a
$cmin :: forall w a.
(Ord w, Ord a) =>
Weighted w a -> Weighted w a -> Weighted w a
max :: Weighted w a -> Weighted w a -> Weighted w a
$cmax :: forall w a.
(Ord w, Ord a) =>
Weighted w a -> Weighted w a -> Weighted w a
>= :: Weighted w a -> Weighted w a -> Bool
$c>= :: forall w a. (Ord w, Ord a) => Weighted w a -> Weighted w a -> Bool
> :: Weighted w a -> Weighted w a -> Bool
$c> :: forall w a. (Ord w, Ord a) => Weighted w a -> Weighted w a -> Bool
<= :: Weighted w a -> Weighted w a -> Bool
$c<= :: forall w a. (Ord w, Ord a) => Weighted w a -> Weighted w a -> Bool
< :: Weighted w a -> Weighted w a -> Bool
$c< :: forall w a. (Ord w, Ord a) => Weighted w a -> Weighted w a -> Bool
compare :: Weighted w a -> Weighted w a -> Ordering
$ccompare :: forall w a.
(Ord w, Ord a) =>
Weighted w a -> Weighted w a -> Ordering
$cp1Ord :: forall w a. (Ord w, Ord a) => Eq (Weighted w a)
Ord,Typeable,Typeable (Weighted w a)
DataType
Constr
Typeable (Weighted w a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Weighted w a -> c (Weighted w a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Weighted w a))
-> (Weighted w a -> Constr)
-> (Weighted w a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Weighted w a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Weighted w a)))
-> ((forall b. Data b => b -> b) -> Weighted w a -> Weighted w a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Weighted w a -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> Weighted w a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a))
-> Data (Weighted w a)
Weighted w a -> DataType
Weighted w a -> Constr
(forall b. Data b => b -> b) -> Weighted w a -> Weighted w a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Weighted w a -> c (Weighted w a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Weighted w a)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Weighted w a))
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) -> Weighted w a -> u
forall u. (forall d. Data d => d -> u) -> Weighted w a -> [u]
forall w a. (Data w, Data a) => Typeable (Weighted w a)
forall w a. (Data w, Data a) => Weighted w a -> DataType
forall w a. (Data w, Data a) => Weighted w a -> Constr
forall w a.
(Data w, Data a) =>
(forall b. Data b => b -> b) -> Weighted w a -> Weighted w a
forall w a u.
(Data w, Data a) =>
Int -> (forall d. Data d => d -> u) -> Weighted w a -> u
forall w a u.
(Data w, Data a) =>
(forall d. Data d => d -> u) -> Weighted w a -> [u]
forall w a r r'.
(Data w, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
forall w a r r'.
(Data w, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
forall w a (m :: * -> *).
(Data w, Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
forall w a (m :: * -> *).
(Data w, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
forall w a (c :: * -> *).
(Data w, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Weighted w a)
forall w a (c :: * -> *).
(Data w, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Weighted w a -> c (Weighted w a)
forall w a (t :: * -> *) (c :: * -> *).
(Data w, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Weighted w a))
forall w a (t :: * -> * -> *) (c :: * -> *).
(Data w, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Weighted w a))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Weighted w a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Weighted w a -> c (Weighted w a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Weighted w a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Weighted w a))
$cWeighted :: Constr
$tWeighted :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
$cgmapMo :: forall w a (m :: * -> *).
(Data w, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
gmapMp :: (forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
$cgmapMp :: forall w a (m :: * -> *).
(Data w, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
gmapM :: (forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
$cgmapM :: forall w a (m :: * -> *).
(Data w, Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Weighted w a -> m (Weighted w a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Weighted w a -> u
$cgmapQi :: forall w a u.
(Data w, Data a) =>
Int -> (forall d. Data d => d -> u) -> Weighted w a -> u
gmapQ :: (forall d. Data d => d -> u) -> Weighted w a -> [u]
$cgmapQ :: forall w a u.
(Data w, Data a) =>
(forall d. Data d => d -> u) -> Weighted w a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
$cgmapQr :: forall w a r r'.
(Data w, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
$cgmapQl :: forall w a r r'.
(Data w, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Weighted w a -> r
gmapT :: (forall b. Data b => b -> b) -> Weighted w a -> Weighted w a
$cgmapT :: forall w a.
(Data w, Data a) =>
(forall b. Data b => b -> b) -> Weighted w a -> Weighted w a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Weighted w a))
$cdataCast2 :: forall w a (t :: * -> * -> *) (c :: * -> *).
(Data w, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Weighted w a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Weighted w a))
$cdataCast1 :: forall w a (t :: * -> *) (c :: * -> *).
(Data w, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Weighted w a))
dataTypeOf :: Weighted w a -> DataType
$cdataTypeOf :: forall w a. (Data w, Data a) => Weighted w a -> DataType
toConstr :: Weighted w a -> Constr
$ctoConstr :: forall w a. (Data w, Data a) => Weighted w a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Weighted w a)
$cgunfold :: forall w a (c :: * -> *).
(Data w, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Weighted w a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Weighted w a -> c (Weighted w a)
$cgfoldl :: forall w a (c :: * -> *).
(Data w, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Weighted w a -> c (Weighted w a)
$cp1Data :: forall w a. (Data w, Data a) => Typeable (Weighted w a)
Data,(forall x. Weighted w a -> Rep (Weighted w a) x)
-> (forall x. Rep (Weighted w a) x -> Weighted w a)
-> Generic (Weighted w a)
forall x. Rep (Weighted w a) x -> Weighted w a
forall x. Weighted w a -> Rep (Weighted w a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall w a x. Rep (Weighted w a) x -> Weighted w a
forall w a x. Weighted w a -> Rep (Weighted w a) x
$cto :: forall w a x. Rep (Weighted w a) x -> Weighted w a
$cfrom :: forall w a x. Weighted w a -> Rep (Weighted w a) x
Generic,a -> Weighted w b -> Weighted w a
(a -> b) -> Weighted w a -> Weighted w b
(forall a b. (a -> b) -> Weighted w a -> Weighted w b)
-> (forall a b. a -> Weighted w b -> Weighted w a)
-> Functor (Weighted w)
forall a b. a -> Weighted w b -> Weighted w a
forall a b. (a -> b) -> Weighted w a -> Weighted w b
forall w a b. a -> Weighted w b -> Weighted w a
forall w a b. (a -> b) -> Weighted w a -> Weighted w b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Weighted w b -> Weighted w a
$c<$ :: forall w a b. a -> Weighted w b -> Weighted w a
fmap :: (a -> b) -> Weighted w a -> Weighted w b
$cfmap :: forall w a b. (a -> b) -> Weighted w a -> Weighted w b
Functor,Weighted w a -> Bool
(a -> m) -> Weighted w a -> m
(a -> b -> b) -> b -> Weighted w a -> b
(forall m. Monoid m => Weighted w m -> m)
-> (forall m a. Monoid m => (a -> m) -> Weighted w a -> m)
-> (forall m a. Monoid m => (a -> m) -> Weighted w a -> m)
-> (forall a b. (a -> b -> b) -> b -> Weighted w a -> b)
-> (forall a b. (a -> b -> b) -> b -> Weighted w a -> b)
-> (forall b a. (b -> a -> b) -> b -> Weighted w a -> b)
-> (forall b a. (b -> a -> b) -> b -> Weighted w a -> b)
-> (forall a. (a -> a -> a) -> Weighted w a -> a)
-> (forall a. (a -> a -> a) -> Weighted w a -> a)
-> (forall a. Weighted w a -> [a])
-> (forall a. Weighted w a -> Bool)
-> (forall a. Weighted w a -> Int)
-> (forall a. Eq a => a -> Weighted w a -> Bool)
-> (forall a. Ord a => Weighted w a -> a)
-> (forall a. Ord a => Weighted w a -> a)
-> (forall a. Num a => Weighted w a -> a)
-> (forall a. Num a => Weighted w a -> a)
-> Foldable (Weighted w)
forall a. Eq a => a -> Weighted w a -> Bool
forall a. Num a => Weighted w a -> a
forall a. Ord a => Weighted w a -> a
forall m. Monoid m => Weighted w m -> m
forall a. Weighted w a -> Bool
forall a. Weighted w a -> Int
forall a. Weighted w a -> [a]
forall a. (a -> a -> a) -> Weighted w a -> a
forall w a. Eq a => a -> Weighted w a -> Bool
forall w a. Num a => Weighted w a -> a
forall w a. Ord a => Weighted w a -> a
forall m a. Monoid m => (a -> m) -> Weighted w a -> m
forall w m. Monoid m => Weighted w m -> m
forall w a. Weighted w a -> Bool
forall w a. Weighted w a -> Int
forall w a. Weighted w a -> [a]
forall b a. (b -> a -> b) -> b -> Weighted w a -> b
forall a b. (a -> b -> b) -> b -> Weighted w a -> b
forall w a. (a -> a -> a) -> Weighted w a -> a
forall w m a. Monoid m => (a -> m) -> Weighted w a -> m
forall w b a. (b -> a -> b) -> b -> Weighted w a -> b
forall w a b. (a -> b -> b) -> b -> Weighted w a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Weighted w a -> a
$cproduct :: forall w a. Num a => Weighted w a -> a
sum :: Weighted w a -> a
$csum :: forall w a. Num a => Weighted w a -> a
minimum :: Weighted w a -> a
$cminimum :: forall w a. Ord a => Weighted w a -> a
maximum :: Weighted w a -> a
$cmaximum :: forall w a. Ord a => Weighted w a -> a
elem :: a -> Weighted w a -> Bool
$celem :: forall w a. Eq a => a -> Weighted w a -> Bool
length :: Weighted w a -> Int
$clength :: forall w a. Weighted w a -> Int
null :: Weighted w a -> Bool
$cnull :: forall w a. Weighted w a -> Bool
toList :: Weighted w a -> [a]
$ctoList :: forall w a. Weighted w a -> [a]
foldl1 :: (a -> a -> a) -> Weighted w a -> a
$cfoldl1 :: forall w a. (a -> a -> a) -> Weighted w a -> a
foldr1 :: (a -> a -> a) -> Weighted w a -> a
$cfoldr1 :: forall w a. (a -> a -> a) -> Weighted w a -> a
foldl' :: (b -> a -> b) -> b -> Weighted w a -> b
$cfoldl' :: forall w b a. (b -> a -> b) -> b -> Weighted w a -> b
foldl :: (b -> a -> b) -> b -> Weighted w a -> b
$cfoldl :: forall w b a. (b -> a -> b) -> b -> Weighted w a -> b
foldr' :: (a -> b -> b) -> b -> Weighted w a -> b
$cfoldr' :: forall w a b. (a -> b -> b) -> b -> Weighted w a -> b
foldr :: (a -> b -> b) -> b -> Weighted w a -> b
$cfoldr :: forall w a b. (a -> b -> b) -> b -> Weighted w a -> b
foldMap' :: (a -> m) -> Weighted w a -> m
$cfoldMap' :: forall w m a. Monoid m => (a -> m) -> Weighted w a -> m
foldMap :: (a -> m) -> Weighted w a -> m
$cfoldMap :: forall w m a. Monoid m => (a -> m) -> Weighted w a -> m
fold :: Weighted w m -> m
$cfold :: forall w m. Monoid m => Weighted w m -> m
Foldable,Functor (Weighted w)
Foldable (Weighted w)
Functor (Weighted w)
-> Foldable (Weighted w)
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Weighted w a -> f (Weighted w b))
-> (forall (f :: * -> *) a.
Applicative f =>
Weighted w (f a) -> f (Weighted w a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Weighted w a -> m (Weighted w b))
-> (forall (m :: * -> *) a.
Monad m =>
Weighted w (m a) -> m (Weighted w a))
-> Traversable (Weighted w)
(a -> f b) -> Weighted w a -> f (Weighted w b)
forall w. Functor (Weighted w)
forall w. Foldable (Weighted w)
forall w (m :: * -> *) a.
Monad m =>
Weighted w (m a) -> m (Weighted w a)
forall w (f :: * -> *) a.
Applicative f =>
Weighted w (f a) -> f (Weighted w a)
forall w (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Weighted w a -> m (Weighted w b)
forall w (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Weighted w a -> f (Weighted w b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
Weighted w (m a) -> m (Weighted w a)
forall (f :: * -> *) a.
Applicative f =>
Weighted w (f a) -> f (Weighted w a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Weighted w a -> m (Weighted w b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Weighted w a -> f (Weighted w b)
sequence :: Weighted w (m a) -> m (Weighted w a)
$csequence :: forall w (m :: * -> *) a.
Monad m =>
Weighted w (m a) -> m (Weighted w a)
mapM :: (a -> m b) -> Weighted w a -> m (Weighted w b)
$cmapM :: forall w (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Weighted w a -> m (Weighted w b)
sequenceA :: Weighted w (f a) -> f (Weighted w a)
$csequenceA :: forall w (f :: * -> *) a.
Applicative f =>
Weighted w (f a) -> f (Weighted w a)
traverse :: (a -> f b) -> Weighted w a -> f (Weighted w b)
$ctraverse :: forall w (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Weighted w a -> f (Weighted w b)
$cp2Traversable :: forall w. Foldable (Weighted w)
$cp1Traversable :: forall w. Functor (Weighted w)
Traversable)
sqr :: Double -> Double
sqr :: Double -> Double
sqr Double
x = Double
x Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
x
{-# INLINE sqr #-}
derivingUnbox "CountG"
[t| forall a. Unbox a => CountG a -> a |]
[| calcCountN |]
[| CountG |]
derivingUnbox "MeanKBN"
[t| MeanKBN -> (Int,Double,Double) |]
[| \(MeanKBN a (KBNSum b c)) -> (a,b,c) |]
[| \(a,b,c) -> MeanKBN a (KBNSum b c) |]
derivingUnbox "Variance"
[t| Variance -> (Int,Double,Double) |]
[| \(Variance a b c) -> (a,b,c) |]
[| \(a,b,c) -> Variance a b c |]
derivingUnbox "MinD"
[t| MinD -> Double |]
[| calcMinD |]
[| MinD |]
derivingUnbox "MaxD"
[t| MaxD -> Double |]
[| calcMaxD |]
[| MaxD |]
derivingUnbox "Weighted"
[t| forall w a. (Unbox w, Unbox a) => Weighted w a -> (w,a) |]
[| \(Weighted w a) -> (w,a) |]
[| \(w,a) -> Weighted w a |]
derivingUnbox "BinomAcc"
[t| BinomAcc -> (Int,Int) |]
[| \(BinomAcc k n) -> (k,n) |]
[| \(k,n) -> BinomAcc k n |]