-- | Basic bounded statistics. In the following, a bound @n@ is given stating-- the number of periods over which to compute the statistic (@n == 1@ computes-- it only over the current period). moduleLanguage.Copilot.Libs.Statistics(max,min,sum,mean,meanNow)whereimportPrelude(Int,($),foldl1,fromIntegral,foldl,error,length)--import qualified Prelude as P importqualifiedLanguage.AtomasAimportLanguage.Copilot.Libs.ErrorChks(nOneChk)importLanguage.Copilot.CoreimportLanguage.Copilot.LanguagefoldDrops::(Streamablea)=>Int->(Speca->Speca->Speca)->Speca->SpecafoldDropsnfs=foldl1f[dropxs|x<-[0..(n-1)]]-- | Summation.sum::(Streamablea,A.NumEa)=>Int->Speca->Specasumns=nOneChk"sum"n$foldDropsn(+)s-- | Maximum value.max::(Streamablea,A.NumEa)=>Int->Speca->Specamaxns=nOneChk"max"n$foldDropsnlargestswherelargest=\xy->mux(x<=y)yx-- | Minimum value.min::(Streamablea,A.NumEa)=>Int->Speca->Specaminns=nOneChk"max"n$foldDropsnsmallestswheresmallest=\xy->mux(x<=y)xy-- | Mean value. @n@ must not overflow-- for word size @a@ for streams over which computation is peformed.mean::(Streamablea,Fractionala,A.NumEa)=>Int->Speca->Specameanns=nOneChk"mean"n$(sumns)/(fromIntegraln)-- | Mean value over the current set of specs passed in.meanNow::(Streamablea,A.IntegralEa)=>[Speca]->SpecameanNow[]=error"Error in majority: list of arguments must be nonempty."meanNowls=(foldl(+)0ls)`div`(fromIntegral$lengthls)