module Numeric.GSL.Statistics (
mean
, variance,variance_m,variance_pm
, stddev,stddev_m,stddev_pm
, tot_sumsq,tot_sumsq_m
, absdev, absdev_m
, skew, skew_m_sd
, kurtosis, kurtosis_m_sd
, mean_w
, variance_w,variance_w_m,variance_w_pm
, stddev_w,stddev_w_m,stddev_w_pm
, tot_sumsq_w,tot_sumsq_w_m
, absdev_w, absdev_w_m
, skew_w, skew_w_m_sd
, kurtosis_w, kurtosis_w_m_sd
, lag1auto
, covariance, covariance_m
, correlation
, median, quantile
) where
import Data.Packed.Vector
import Data.Packed.Development
import Foreign
import Foreign.C.Types(CInt(..))
import System.IO.Unsafe(unsafePerformIO)
type PD = Ptr Double
getD1 f s v = unsafePerformIO $ do
alloca $ \r -> do
app1 (f r) vec v s
r' <- peek r
return r'
getD2 f s v w = unsafePerformIO $ do
alloca $ \r -> do
app2 (f r) vec v vec w s
r' <- peek r
return r'
mean :: Vector Double -> Double
mean = getD1 statistics_mean "mean"
variance :: Vector Double -> Double
variance = getD1 statistics_variance "variance"
variance_m :: Double -> Vector Double -> Double
variance_m m = getD1 (statistics_variance_m m) "variance_m"
variance_pm :: Double -> Vector Double -> Double
variance_pm m = getD1 (statistics_var_with_fixed_m m) "variance_pm"
stddev :: Vector Double -> Double
stddev = getD1 statistics_stddev "stddev"
stddev_m :: Double -> Vector Double -> Double
stddev_m m = getD1 (statistics_stddev_m m) "stddev_m"
stddev_pm :: Double -> Vector Double -> Double
stddev_pm m = getD1 (statistics_stddev_with_fixed_m m) "stddev_pm"
tot_sumsq :: Vector Double -> Double
tot_sumsq = getD1 statistics_tot_sumsq "tot_sumsq"
tot_sumsq_m :: Double -> Vector Double -> Double
tot_sumsq_m m = getD1 (statistics_tot_sumsq_m m) "totsumsq_m"
foreign import ccall "statistics-aux.h mean" statistics_mean :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h variance" statistics_variance :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h variance_m" statistics_variance_m :: Double -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h var_with_fixed_m" statistics_var_with_fixed_m :: Double -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h stddev" statistics_stddev :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h stddev_m" statistics_stddev_m :: Double -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h stddev_with_fixed_m" statistics_stddev_with_fixed_m :: Double -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h tot_sumsq" statistics_tot_sumsq :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h tot_sumsq_m" statistics_tot_sumsq_m :: Double -> PD -> CInt -> PD -> IO CInt
absdev :: Vector Double -> Double
absdev = getD1 statistics_absdev "absdev"
absdev_m :: Double -> Vector Double -> Double
absdev_m m = getD1 (statistics_absdev_m m) "absdev_m"
foreign import ccall "statistics-aux.h absdev" statistics_absdev :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h absdev_m" statistics_absdev_m :: Double -> PD -> CInt -> PD -> IO CInt
skew :: Vector Double -> Double
skew = getD1 statistics_skew "skew"
skew_m_sd :: Double -> Double -> Vector Double -> Double
skew_m_sd m sd = getD1 (statistics_skew_m_sd m sd) "skew_m_sd"
kurtosis :: Vector Double -> Double
kurtosis = getD1 statistics_kurtosis "kurtosis"
kurtosis_m_sd :: Double -> Double -> Vector Double -> Double
kurtosis_m_sd m sd = getD1 (statistics_kurtosis_m_sd m sd) "kurtosis_m_sd"
foreign import ccall "statistics-aux.h skew" statistics_skew :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h skew_m_sd" statistics_skew_m_sd :: Double -> Double -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h kurtosis" statistics_kurtosis :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h kurtosis_m_sd" statistics_kurtosis_m_sd :: Double -> Double -> PD -> CInt -> PD -> IO CInt
lag1auto :: Vector Double -> Double
lag1auto = getD1 statistics_lag1auto "lag1auto"
foreign import ccall "statistics-aux.h lag1_autocorrelation" statistics_lag1auto :: PD -> CInt -> PD -> IO CInt
covariance :: Vector Double -> Vector Double -> Double
covariance = getD2 statistics_covariance "covariance"
covariance_m :: Double -> Double -> Vector Double -> Vector Double -> Double
covariance_m m1 m2 = getD2 (statistics_covariance_m m1 m2) "covariance_m"
foreign import ccall "statistics-aux.h covariance" statistics_covariance :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h covariance_m" statistics_covariance_m :: Double -> Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
correlation :: Vector Double -> Vector Double -> Double
correlation = getD2 statistics_correlation "correlation"
foreign import ccall "statistics-aux.h correlation" statistics_correlation :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
mean_w :: Vector Double
-> Vector Double
-> Double
mean_w = getD2 statistics_w_mean "w_mean"
variance_w :: Vector Double -> Vector Double -> Double
variance_w = getD2 statistics_w_variance "w_variance"
variance_w_m :: Double -> Vector Double -> Vector Double -> Double
variance_w_m m = getD2 (statistics_w_variance_m m) "w_variance_m"
variance_w_pm :: Double -> Vector Double -> Vector Double -> Double
variance_w_pm m = getD2 (statistics_w_var_with_fixed_m m) "w_variance_pm"
stddev_w :: Vector Double -> Vector Double -> Double
stddev_w = getD2 statistics_w_stddev "w_stddev"
stddev_w_m :: Double -> Vector Double -> Vector Double -> Double
stddev_w_m m = getD2 (statistics_w_stddev_m m) "w_stddev_m"
stddev_w_pm :: Double -> Vector Double -> Vector Double -> Double
stddev_w_pm m = getD2 (statistics_w_stddev_with_fixed_m m) "w_stddev_pm"
tot_sumsq_w :: Vector Double -> Vector Double -> Double
tot_sumsq_w = getD2 statistics_w_tot_sumsq "w_tot_sumsq"
tot_sumsq_w_m :: Double -> Vector Double -> Vector Double -> Double
tot_sumsq_w_m m = getD2 (statistics_w_tot_sumsq_m m) "w_totsumsq_m"
foreign import ccall "statistics-aux.h w_mean" statistics_w_mean :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_variance" statistics_w_variance :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_variance_m" statistics_w_variance_m :: Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_var_with_fixed_m" statistics_w_var_with_fixed_m :: Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_stddev" statistics_w_stddev :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_stddev_m" statistics_w_stddev_m :: Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_stddev_with_fixed_m" statistics_w_stddev_with_fixed_m :: Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_tot_sumsq" statistics_w_tot_sumsq :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_tot_sumsq_m" statistics_w_tot_sumsq_m :: Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
absdev_w :: Vector Double -> Vector Double -> Double
absdev_w = getD2 statistics_w_absdev "w_absdev"
absdev_w_m :: Double -> Vector Double -> Vector Double -> Double
absdev_w_m m = getD2 (statistics_w_absdev_m m) "w_absdev_m"
foreign import ccall "statistics-aux.h w_absdev" statistics_w_absdev :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_absdev_m" statistics_w_absdev_m :: Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
skew_w :: Vector Double -> Vector Double -> Double
skew_w = getD2 statistics_w_skew "w_skew"
skew_w_m_sd :: Double -> Double -> Vector Double -> Vector Double -> Double
skew_w_m_sd m sd = getD2 (statistics_w_skew_m_sd m sd) "w_skew_m_sd"
kurtosis_w :: Vector Double -> Vector Double -> Double
kurtosis_w = getD2 statistics_w_kurtosis "w_kurtosis"
kurtosis_w_m_sd :: Double -> Double -> Vector Double -> Vector Double -> Double
kurtosis_w_m_sd m sd = getD2 (statistics_w_kurtosis_m_sd m sd) "w_kurtosis_m_sd"
foreign import ccall "statistics-aux.h w_skew" statistics_w_skew :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_skew_m_sd" statistics_w_skew_m_sd :: Double -> Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_kurtosis" statistics_w_kurtosis :: PD -> CInt -> PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h w_kurtosis_m_sd" statistics_w_kurtosis_m_sd :: Double -> Double -> PD -> CInt -> PD -> CInt -> PD -> IO CInt
median :: Vector Double -> Double
median = getD1 statistics_median "median"
quantile :: Double
-> Vector Double
-> Double
quantile f = getD1 (statistics_quantile f) "quantile"
foreign import ccall "statistics-aux.h median" statistics_median :: PD -> CInt -> PD -> IO CInt
foreign import ccall "statistics-aux.h quantile" statistics_quantile :: Double -> PD -> CInt -> PD -> IO CInt