Copyright | (c) A. V. H. McPhail 2010 |
---|---|
License | BSD3 |
Maintainer | haskell.vivian.mcphail <at> gmail <dot> com |
Stability | provisional |
Portability | uses ffi |
Safe Haskell | None |
Language | Haskell2010 |
GSL 2D histogram functions
- data Histogram2D
- emptyRanges :: Vector Double -> Vector Double -> Histogram2D
- emptyLimits :: Int -> Int -> (Double, Double) -> (Double, Double) -> Histogram2D
- fromRanges :: Vector Double -> Vector Double -> [(Double, Double)] -> Histogram2D
- fromLimits :: Int -> Int -> (Double, Double) -> (Double, Double) -> [(Double, Double)] -> Histogram2D
- addList :: Histogram2D -> [(Double, Double)] -> Histogram2D
- addVector :: Histogram2D -> Vector Double -> Vector Double -> Histogram2D
- addListWeighted :: Histogram2D -> [(Double, Double, Double)] -> Histogram2D
- addVectorWeighted :: Histogram2D -> Vector Double -> Vector Double -> Vector Double -> Histogram2D
- toMatrix :: Histogram2D -> (Vector Double, Vector Double, Matrix Double)
- fromMatrix :: Vector Double -> Vector Double -> Matrix Double -> Histogram2D
- getBin :: Histogram2D -> (Int, Int) -> Double
- getXRange :: Histogram2D -> Int -> (Double, Double)
- getYRange :: Histogram2D -> Int -> (Double, Double)
- getXMax :: Histogram2D -> Double
- getYMax :: Histogram2D -> Double
- getXMin :: Histogram2D -> Double
- getYMin :: Histogram2D -> Double
- getXBins :: Histogram2D -> Int
- getYBins :: Histogram2D -> Int
- reset :: Histogram2D -> IO ()
- find :: Histogram2D -> (Double, Double) -> Maybe (Int, Int)
- count :: Histogram2D -> (Vector Double, Vector Double) -> Vector Double
- prob :: Histogram2D -> (Vector Double, Vector Double) -> Vector Double
- probPaired :: Histogram2D -> Vector (Double, Double) -> Vector Double
- countPaired :: Histogram2D -> Vector (Double, Double) -> Vector Double
- countInstance :: Histogram2D -> (Double, Double) -> Double
- probability :: Histogram2D -> (Double, Double) -> Double
- maxVal :: Histogram2D -> Double
- maxBin :: Histogram2D -> (Int, Int)
- minVal :: Histogram2D -> Double
- minBin :: Histogram2D -> (Int, Int)
- xmean :: Histogram2D -> Double
- ymean :: Histogram2D -> Double
- xstddev :: Histogram2D -> Double
- ystddev :: Histogram2D -> Double
- covariance :: Histogram2D -> Double
- sum :: Histogram2D -> Double
- equalBins :: Histogram2D -> Histogram2D -> Bool
- add :: Histogram2D -> Histogram2D -> Histogram2D
- subtract :: Histogram2D -> Histogram2D -> Histogram2D
- multiply :: Histogram2D -> Histogram2D -> Histogram2D
- divide :: Histogram2D -> Histogram2D -> Histogram2D
- shift :: Histogram2D -> Double -> Histogram2D
- scale :: Histogram2D -> Double -> Histogram2D
- fwriteHistogram2D :: FilePath -> Histogram2D -> IO ()
- freadHistogram2D :: FilePath -> Int -> Int -> IO Histogram2D
- fprintfHistogram2D :: FilePath -> String -> String -> Histogram2D -> IO ()
- fscanfHistogram2D :: FilePath -> Int -> Int -> IO Histogram2D
- data Histogram2DPDF
- fromHistogram2D :: Histogram2D -> Histogram2DPDF
- sample :: Histogram2DPDF -> Double -> Double
Creation
:: Vector Double | the x ranges |
-> Vector Double | the y ranges |
-> Histogram2D | result |
create a histogram with n bins from ranges (x0->x1),(x1->x2)..(xn->xn+1)
:: Int | |
-> Int | bins |
-> (Double, Double) | lower and upper limits x |
-> (Double, Double) | lower and upper limits y |
-> Histogram2D | result |
create a histogram with n bins and lower and upper limits
:: Vector Double | the x ranges |
-> Vector Double | the y ranges |
-> [(Double, Double)] | the data |
-> Histogram2D | result |
create a histogram with n bins from ranges (x0->x1),(x1->x2)..(xn->xn+1) and increment from a vector
:: Int | |
-> Int | bins |
-> (Double, Double) | x lower and upper limits |
-> (Double, Double) | y lower and upper limits |
-> [(Double, Double)] | the data |
-> Histogram2D | result |
create a histogram with n bins and lower and upper limits and increment from a vector
Loading
addList :: Histogram2D -> [(Double, Double)] -> Histogram2D Source
add 1.0 to the correct bin for each element of the list, fails silently if the value is outside the range
addVector :: Histogram2D -> Vector Double -> Vector Double -> Histogram2D Source
add 1.0 to the correct bin for each element of the vector pair, fails silently if the value is outside the range
addListWeighted :: Histogram2D -> [(Double, Double, Double)] -> Histogram2D Source
addVectorWeighted :: Histogram2D -> Vector Double -> Vector Double -> Vector Double -> Histogram2D Source
Marshalling
extract the ranges and bins
:: Vector Double | x ranges |
-> Vector Double | y ranges |
-> Matrix Double | bins (row major) |
-> Histogram2D | result |
create from ranges and bins
Information
getXRange :: Histogram2D -> Int -> (Double, Double) Source
returns the upper and lower limits in the first dimension of the i-th bin
getYRange :: Histogram2D -> Int -> (Double, Double) Source
returns the upper and lower limits in the second dimension of the i-th bin
getXMax :: Histogram2D -> Double Source
the maximum upper range limit in the first dimension
getYMax :: Histogram2D -> Double Source
the maximum upper range limit in the first dimension
getXMin :: Histogram2D -> Double Source
the minimum lower range limit in the first dimension
getYMin :: Histogram2D -> Double Source
the minimum lower range limit in the first dimension
getXBins :: Histogram2D -> Int Source
the number of binsin the first dimension
getYBins :: Histogram2D -> Int Source
the number of binsin the first dimension
reset :: Histogram2D -> IO () Source
reset all the bins to zero
Querying
find :: Histogram2D -> (Double, Double) -> Maybe (Int, Int) Source
find the bin corresponding to the value
count :: Histogram2D -> (Vector Double, Vector Double) -> Vector Double Source
find the number of occurences for each element of the input vector
prob :: Histogram2D -> (Vector Double, Vector Double) -> Vector Double Source
find the joint probability of occuring for each element of the input vector pair
probPaired :: Histogram2D -> Vector (Double, Double) -> Vector Double Source
find the joint probability of occuring for each element of the input vector pair
countPaired :: Histogram2D -> Vector (Double, Double) -> Vector Double Source
find the number of occurences for each element of the input vector
countInstance :: Histogram2D -> (Double, Double) -> Double Source
find the number of occurences for the input
probability :: Histogram2D -> (Double, Double) -> Double Source
find the probability of the input
maxVal :: Histogram2D -> Double Source
the maximum value contained in the bins
maxBin :: Histogram2D -> (Int, Int) Source
the index of the bin containing the maximum value
minVal :: Histogram2D -> Double Source
the minimum value contained in the bins
minBin :: Histogram2D -> (Int, Int) Source
the index of the bin containing the minimum value
Statistics
xmean :: Histogram2D -> Double Source
the mean of the values in the first dimension, accuracy limited by bin width
ymean :: Histogram2D -> Double Source
the mean of the values in the second dimension, accuracy limited by bin width
xstddev :: Histogram2D -> Double Source
the standard deviation of the values in thee first dimension, accuracy limited by bin width
ystddev :: Histogram2D -> Double Source
the standard deviation of the values in thee first dimension, accuracy limited by bin width
covariance :: Histogram2D -> Double Source
the covariance of the first and second dimensions
sum :: Histogram2D -> Double Source
the sum of the values, accuracy limited by bin width
equalBins :: Histogram2D -> Histogram2D -> Bool Source
returns True of all the individual bin ranges of the two histograms are identical
Mathematics
add :: Histogram2D -> Histogram2D -> Histogram2D Source
adds the contents of the bins of the second histogram to the first
subtract :: Histogram2D -> Histogram2D -> Histogram2D Source
subtracts the contents of the bins of the second histogram from the first
multiply :: Histogram2D -> Histogram2D -> Histogram2D Source
multiplies the contents of the bins of the second histogram by the first
divide :: Histogram2D -> Histogram2D -> Histogram2D Source
divides the contents of the bins of the first histogram by the second
shift :: Histogram2D -> Double -> Histogram2D Source
adds a constant to the contents of the bins
scale :: Histogram2D -> Double -> Histogram2D Source
multiplies the contents of the bins by a constant
Files
fwriteHistogram2D :: FilePath -> Histogram2D -> IO () Source
write a histogram in the native binary format (may not be portable)
freadHistogram2D :: FilePath -> Int -> Int -> IO Histogram2D Source
read a histogram in the native binary format, number of bins must be known
fprintfHistogram2D :: FilePath -> String -> String -> Histogram2D -> IO () Source
saves the histogram with the given formats (%f,%e,%g) for ranges and bins each line comprises: xrange[i] xrange[i+1] xrange[j] xrange[j+1] bin(i,j)
fscanfHistogram2D :: FilePath -> Int -> Int -> IO Histogram2D Source
reads formatted data as written by fprintf, the number of bins must be known in advance
data Histogram2DPDF Source
A histogram-derived cumulative distribution function (CDF)
fromHistogram2D :: Histogram2D -> Histogram2DPDF Source
create a histogram PDF from a histogram
sample :: Histogram2DPDF -> Double -> Double Source
given a randomm from the uniform distribution [0,1], draw a random sample from the PDF