packages feed

statistics 0.10.3.0 → 0.10.3.1

raw patch · 7 files changed

+289/−4 lines, 7 files

Files

+ ChangeLog view
@@ -0,0 +1,110 @@+ Changes in 0.10.2.0++  * Bugs in DCT and IDCT are fixed.++  * Accesors for uniform distribution are added.++  * ContGen instances for all continous distribtuions are added.++  * Beta distribution is added.++  * Constructor for improper gamma distribtuion is added.++  * Binomial distribution allows zero trials.++  * Poisson distribution now accept zero parameter.++  * Integer overflow in caculation of Wilcoxon-T test is fixed.++  * Bug in 'ContGen' instance for normal distribution is fixed.++Changes in 0.10.1.0++  * Kolmogorov-Smirnov nonparametric test added.++  * Pearson chi squared test added.++  * Type class for generating random variates for given distribution+    is added.++  * Modules 'Statistics.Math' and 'Statistics.Constants' are moved to+    the @math-functions@ package. They are still available but marked+    as deprecated.+++Changed in 0.10.0.1++  * @dct@ and @idct@ now have type @Vector Double -> Vector Double@+++Changes in 0.10.0.0++  * The type classes Mean and Variance are split in two. This is+    required for distributions which do not have finite variance or+    mean.++  * The S.Sample.KernelDensity module has been renamed, and+    completely rewritten to be much more robust.  The older module+    oversmoothed multi-modal data.  (The older module is still+    available under the name S.Sample.KernelDensity.Simple).++  * Histogram computation is added, in S.Sample.Histogram.++  * Discrete Fourie transform is added, in S.Transform++  * Root finding is added, in S.Math.RootFinding.++  * The complCumulative function is added to the Distribution+    class in order to accurately assess probalities P(X>x) which are+    used in one-tailed tests.++  * A stdDev function is added to the Variance class for+    distributions.++  * The constructor S.Distribution.normalDistr now takes standard+    deviation instead of variance as its parameter.++  * A bug in S.Quantile.weightedAvg is fixed. It produced a wrong+    answer if a sample contained only one element.++  * Bugs in quantile estimations for chi-square and gamma distribution+    are fixed.++  * Integer overlow in mannWhitneyUCriticalValue is fixed. It+    produced incorrect critical values for moderately large+    samples. Something around 20 for 32-bit machines and 40 for 64-bit+    ones.++  * A bug in mannWhitneyUSignificant is fixed. If either sample was+    larger than 20, it produced a completely incorrect answer.++  * One- and two-tailed tests in S.Tests.NonParametric are selected+    with sum types instead of Bool.++  * Test results returned as enumeration instead of @Bool@.++  * Performance improvements for Mann-Whitney U and Wilcoxon tests.++  * Module @S.Tests.NonParamtric@ is split into @S.Tests.MannWhitneyU@+    and @S.Tests.WilcoxonT@++  * sortBy is added to S.Function.++  * Mean and variance for gamma distribution are fixed.++  * Much faster cumulative probablity functions for Poisson and+    hypergeometric distributions.++  * Better density functions for gamma and Poisson distributions.++  * Student-T, Fisher-Snedecor F-distributions and Cauchy-Lorentz+    distrbution are added.++  * The function S.Function.create is removed. Use generateM from+    the vector package instead.++  * Function to perform approximate comparion of doubles is added to+    S.Function.Comparison++  * Regularized incomplete beta function and its inverse are added to+    S.Function
Statistics/Distribution/Transform.hs view
@@ -25,11 +25,11 @@ -- > x' = μ + σ·x data LinearTransform d = LinearTransform   { linTransLocation :: {-# UNPACK #-} !Double-    -- | Location parameter.+    -- ^ Location parameter.   , linTransScale    :: {-# UNPACK #-} !Double-    -- | Scale parameter.+    -- ^ Scale parameter.   , linTransDistr    :: d-    -- | Distribution being transformed.+    -- ^ Distribution being transformed.   } deriving (Eq,Show,Read,Typeable)  -- | Apply linear transformation to distribution.
+ benchmark/bench.hs view
@@ -0,0 +1,68 @@+import Control.Monad.ST (runST)+import Data.Complex+import qualified Data.Vector.Unboxed as U++import System.Random.MWC+import Criterion.Main++import Statistics.Sample+import Statistics.Transform+++-- Test sample+sample :: U.Vector Double+sample = runST $ flip uniformVector 10000 =<< create++-- Weighted test sample+sampleW :: U.Vector (Double,Double)+sampleW = U.zip sample (U.reverse sample)++-- Comlex vector for FFT tests+sampleC :: U.Vector (Complex Double)+sampleC = U.zipWith (:+) sample (U.reverse sample)+++-- Simple benchmark for functions from Statistics.Sample+main :: IO ()+main =+  defaultMain+  [ bgroup "sample"+    [ bench "range"            $ nf (\x -> range x)            sample+      -- Mean+    , bench "mean"             $ nf (\x -> mean x)             sample+    , bench "meanWeighted"     $ nf (\x -> meanWeighted x)     sampleW+    , bench "harmonicMean"     $ nf (\x -> harmonicMean x)     sample+    , bench "geometricMean"    $ nf (\x -> geometricMean x)    sample+      -- Variance+    , bench "variance"         $ nf (\x -> variance x)         sample+    , bench "varianceUnbiased" $ nf (\x -> varianceUnbiased x) sample+    , bench "varianceWeighted" $ nf (\x -> varianceWeighted x) sampleW+      -- Other+    , bench "stdDev"           $ nf (\x -> stdDev x)           sample+    , bench "skewness"         $ nf (\x -> skewness x)         sample+    , bench "kurtosis"         $ nf (\x -> kurtosis x)         sample+      -- Central moments+    , bench "C.M. 2"           $ nf (\x -> centralMoment 2 x)  sample+    , bench "C.M. 3"           $ nf (\x -> centralMoment 3 x)  sample+    , bench "C.M. 4"           $ nf (\x -> centralMoment 4 x)  sample+    , bench "C.M. 5"           $ nf (\x -> centralMoment 5 x)  sample+    ]+  , bgroup "FFT"+    [ bgroup "fft"+      [ bench  (show n) $ whnf fft   (U.take n sampleC) | n <- fftSizes ]+    , bgroup "ifft"+      [ bench  (show n) $ whnf ifft  (U.take n sampleC) | n <- fftSizes ]+    , bgroup "dct"+      [ bench  (show n) $ whnf dct   (U.take n sample)  | n <- fftSizes ]+    , bgroup "dct_"+      [ bench  (show n) $ whnf dct_  (U.take n sampleC) | n <- fftSizes ]+    , bgroup "idct"+      [ bench  (show n) $ whnf idct  (U.take n sample)  | n <- fftSizes ]+    , bgroup "idct_"+      [ bench  (show n) $ whnf idct_ (U.take n sampleC) | n <- fftSizes ]+    ]+  ]+++fftSizes :: [Int]+fftSizes = [32,128,512,2048]
statistics.cabal view
@@ -1,5 +1,5 @@ name:           statistics-version:        0.10.3.0+version:        0.10.3.1 synopsis:       A library of statistical types, data, and functions description:   This library provides a number of common functions and types useful@@ -147,12 +147,17 @@ build-type:     Simple cabal-version:  >= 1.8 extra-source-files:+  ChangeLog   README.markdown+  benchmark/bench.hs   examples/kde/KDE.hs   examples/kde/data/faithful.csv   examples/kde/kde.html   examples/kde/kde.tpl   tests/Tests/Math/gen.py+  tests/Tests/Math/Tables.hs+  tests/utils/Makefile+  tests/utils/fftw.c  library   exposed-modules:
+ tests/Tests/Math/Tables.hs view
@@ -0,0 +1,47 @@+module Tests.Math.Tables where++tableLogGamma :: [(Double,Double)]+tableLogGamma =+  [(0.000001250000000, 13.592366285131769033)+  , (0.000068200000000, 9.5930266308318756785)+  , (0.000246000000000, 8.3100370767447966358)+  , (0.000880000000000, 7.03508133735248542)+  , (0.003120000000000, 5.768129358365567505)+  , (0.026700000000000, 3.6082588918892977148)+  , (0.077700000000000, 2.5148371858768232556)+  , (0.234000000000000, 1.3579557559432759994)+  , (0.860000000000000, 0.098146578027685615897)+  , (1.340000000000000, -0.11404757557207759189)+  , (1.890000000000000, -0.0425116422978701336)+  , (2.450000000000000, 0.25014296569217625565)+  , (3.650000000000000, 1.3701041997380685178)+  , (4.560000000000000, 2.5375143317949580002)+  , (6.660000000000000, 5.9515377269550207018)+  , (8.250000000000000, 9.0331869196051233217)+  , (11.300000000000001, 15.814180681373947834)+  , (25.600000000000001, 56.711261598328121636)+  , (50.399999999999999, 146.12815158702164808)+  , (123.299999999999997, 468.85500075897556371)+  , (487.399999999999977, 2526.9846647543727158)+  , (853.399999999999977, 4903.9359135978220365)+  , (2923.300000000000182, 20402.93198938705973)+  , (8764.299999999999272, 70798.268343590112636)+  , (12630.000000000000000, 106641.77264982508495)+  , (34500.000000000000000, 325976.34838781820145)+  , (82340.000000000000000, 849629.79603036714252)+  , (234800.000000000000000, 2668846.4390507959761)+  , (834300.000000000000000, 10540830.912557534873)+  , (1230000.000000000000000, 16017699.322315014899)+  ]+tableIncompleteBeta :: [(Double,Double,Double,Double)]+tableIncompleteBeta =+  [(2.000000000000000, 3.000000000000000, 0.030000000000000, 0.0051864299999999996862)+  , (2.000000000000000, 3.000000000000000, 0.230000000000000, 0.22845923000000001313)+  , (2.000000000000000, 3.000000000000000, 0.760000000000000, 0.95465728000000005249)+  , (4.000000000000000, 2.300000000000000, 0.890000000000000, 0.93829812158347802864)+  , (1.000000000000000, 1.000000000000000, 0.550000000000000, 0.55000000000000004441)+  , (0.300000000000000, 12.199999999999999, 0.110000000000000, 0.95063000053947077639)+  , (13.100000000000000, 9.800000000000001, 0.120000000000000, 1.3483109941962659385e-07)+  , (13.100000000000000, 9.800000000000001, 0.420000000000000, 0.071321857831804780226)+  , (13.100000000000000, 9.800000000000001, 0.920000000000000, 0.99999578339197081611)+  ]
+ tests/utils/Makefile view
@@ -0,0 +1,9 @@+C       = gcc+CFLAGS  = -W -Wall -O2 -std=c99+LDFLAGS = -lfftw3++.PHONY: all clean++all : fftw+clean :+	rm -rf fftw *.o
+ tests/utils/fftw.c view
@@ -0,0 +1,46 @@+/* Generate some test cases using fftw3  */+#include <stdlib.h>+#include <stdio.h>+#include <fftw3.h>++void dump_vector(int n, double* vec) {+    for(int i = 0; i < n; i++)+        printf("%20.15f ", vec[i]);+    printf("\n");+}++void dct(int flag, int n) {+    double* in  = malloc( n * sizeof(double));+    double* out = malloc( n * sizeof(double));+    //+    fftw_plan plan = fftw_plan_r2r_1d(n, in, out, flag, FFTW_ESTIMATE);+    for( int k = 0; k < n; k++) {+        // Init input vector+        for( int i = 0; i < n; i++)+            in[i] = 0;+        in[k] = 1;+        // Perform DFT+        fftw_execute(plan);+        // Print results+        dump_vector(n, in );+        dump_vector(n, out);+        printf("\n");+    }+    //+    free(in);+    free(out);+    fftw_destroy_plan(plan);+}++int main(void)+{+    printf("DCT II (the DCT)\n");+    dct( FFTW_REDFT10, 2);+    dct( FFTW_REDFT10, 4);+    +    printf("DCT III (Inverse DCT)\n");+    dct( FFTW_REDFT01, 2);+    dct( FFTW_REDFT01, 4);+    +    return 0;    +}