packages feed

hmatrix-gsl-stats 0.1.0.1 → 0.1.1.1

raw patch · 5 files changed

+42/−5 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Numeric.GSL.Histogram: prob :: Histogram -> Vector Double -> Vector Double
+ Numeric.GSL.Histogram2D: prob :: Histogram2D -> (Vector Double, Vector Double) -> Vector Double
- Numeric.GSL.Histogram2D: getBin :: Histogram2D -> Int -> Int -> Double
+ Numeric.GSL.Histogram2D: getBin :: Histogram2D -> (Int, Int) -> Double

Files

CHANGES view
@@ -1,2 +1,6 @@ 0.1.0.1:	 		renamed from hstatistics 0.1.0.5++0.1.1.1:+		added prob to Histogram, Histogram2D+		changed return of getBins to curried form
hmatrix-gsl-stats.cabal view
@@ -1,5 +1,5 @@ Name:               hmatrix-gsl-stats-Version:            0.1.0.1+Version:            0.1.1.1 License:            GPL License-file:       LICENSE Copyright:          (c) A.V.H. McPhail 2010
lib/Numeric/GSL/Histogram.hs view
@@ -20,7 +20,8 @@                              , toVectors                              , getBin, getRange                              , getMax, getMin, getBins-                             , find+                             , find +                             , prob                              , maxVal, maxBin, minVal, minBin                              , mean, stddev, sum                              , equalBins@@ -276,6 +277,13 @@                      else return Nothing  foreign import ccall "gsl-histogram.h gsl_histogram_find" histogram_find :: HistHandle -> Double -> Ptr CInt -> IO CInt++-- | find the probability of occurring for each element of the input vector+prob :: Histogram -> Vector Double -> Vector Double+prob h = mapVector (\x -> let s = sum h+                              Just x' = find h x+                              b = getBin h x'+                          in b/s)   ----------------------------------------------------------------------------- 
lib/Numeric/GSL/Histogram2D.hs view
@@ -22,6 +22,7 @@                                , getXMax, getYMax, getXMin, getYMin, getXBins, getYBins                                , reset                                , find+                               , prob                                , maxVal, maxBin, minVal, minBin                                , xmean, ymean, xstddev, ystddev, covariance, sum                                , equalBins@@ -234,9 +235,9 @@ accumulateListIO (H _ _ h) zs = withForeignPtr h (\f -> mapM_ (\(x,y,w) -> histogram2d_accumulate f x y w) zs)  -- | returns the contents of the i-th bin-getBin :: Histogram2D -> Int -> Int -> Double-getBin (H _ _ h) bx by = unsafePerformIO $ do-                         withForeignPtr h (\f -> histogram2d_get f (fromIntegral bx) (fromIntegral by))+getBin :: Histogram2D -> (Int,Int) -> Double+getBin (H _ _ h) (bx,by) = unsafePerformIO $ do+                           withForeignPtr h (\f -> histogram2d_get f (fromIntegral bx) (fromIntegral by))  -- | returns the upper and lower limits in the first dimension of the i-th bin getXRange :: Histogram2D -> Int -> (Double,Double)@@ -318,6 +319,15 @@                               else return Nothing  foreign import ccall "gsl-histogram2d.h gsl_histogram2d_find" histogram2d_find :: Hist2DHandle -> Double -> Double -> Ptr CInt -> Ptr CInt -> IO CInt++-- | find the probability of occuring for each element of the input vector+prob :: Histogram2D -> (Vector Double,Vector Double) -> Vector Double+prob (H _ _ h) (x,y) = unsafePerformIO $ do+               r <- createVector $ dim x+               app3 (\xs' x' ys' y' rs' r' -> withForeignPtr h $ \h' -> histogram2d_prob h' xs' x' ys' y' rs' r') vec x vec y vec r "histogram2d_prob"+               return r++foreign import ccall "histogram-aux.h hist2d_prob" histogram2d_prob :: Hist2DHandle -> CInt -> Ptr Double -> CInt -> Ptr Double -> CInt -> Ptr Double -> IO CInt  ----------------------------------------------------------------------------- 
lib/Numeric/GSL/histogram-aux.c view
@@ -109,6 +109,21 @@   return 0; } +int hist2d_prob(gsl_histogram2d* H, int xs, const double* x, int ys, const double* y, int rs, double* res)+{+  if (xs != ys) return 2000; // BAD_SIZE+  if (xs != rs) return 2000; // BAD_SIZE+  int i;+  int r,c;+  int err;+  for (i = 0; i < xs; i++) {+    err = gsl_histogram2d_find(H,x[i],y[i],&r,&c);+    if (err != 0) return 0;+    else { res[i] = gsl_histogram2d_get(H,r,c); }+  }+  return 0;+}+       int hist2d_fwrite(const char* filename, const gsl_histogram2d* h) {   int err;