| Copyright | David Johnson (c) 2019-2026 |
|---|---|
| License | BSD3 |
| Maintainer | David Johnson <code@dmj.io> |
| Stability | Experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
ArrayFire.Statistics
Description
Statistics API.
Example of finding the top k elements along with their indices from an Array
>>> let (vals,indexes) =topk(vector@Double10 [1..] ) 3TopKDefault>>> vals ArrayFire Array [3 1 1 1] 10.0000 9.0000 8.0000 >>> indexes ArrayFire Array [3 1 1 1] 9 8 7
Synopsis
- mean :: (AFType a, Fractional a) => Array a -> Int -> Array a
- meanWeighted :: (AFType a, Fractional a) => Array a -> Array a -> Int -> Array a
- var :: (AFType a, Fractional a) => Array a -> VarianceType -> Int -> Array a
- data VarianceType
- = Population
- | Sample
- varWeighted :: (AFType a, Fractional a) => Array a -> Array a -> Int -> Array a
- stdev :: (AFType a, Fractional a) => Array a -> Int -> Array a
- cov :: (AFType a, Fractional a) => Array a -> Array a -> Bool -> Array a
- median :: (AFType a, Fractional a) => Array a -> Int -> Array a
- meanAll :: AFResult a => Array a -> Scalar a
- meanAllWeighted :: AFResult a => Array a -> Array a -> Scalar a
- varAll :: AFResult a => Array a -> VarianceType -> Scalar a
- varAllWeighted :: AFResult a => Array a -> Array a -> Scalar a
- stdevAll :: AFResult a => Array a -> Scalar a
- medianAll :: AFResult a => Array a -> Scalar a
- corrCoef :: AFResult a => Array a -> Array a -> Scalar a
- topk :: AFType a => Array a -> Int -> TopK -> (Array a, Array Word32)
- meanVar :: (AFType a, Fractional a) => Array a -> VarBias -> Int -> (Array a, Array a)
- meanVarWeighted :: (AFType a, Fractional a) => Array a -> Array a -> VarBias -> Int -> (Array a, Array a)
Documentation
Arguments
| :: (AFType a, Fractional a) | |
| => Array a | Input |
| -> Array a | Weights |
| -> Int | The dimension along which the mean is extracted |
| -> Array a | Will contain the mean of the input |
Calculates meanWeighted of Array along user-specified dimension.
>>>meanWeighted (vector @Double 10 [1..10]) (vector @Double 10 [1..10]) 0ArrayFire Array [1 1 1 1] 7.0000
Arguments
| :: (AFType a, Fractional a) | |
| => Array a | Input |
| -> VarianceType | boolean denoting Population variance (false) or Sample Variance (true) |
| -> Int | The dimension along which the variance is extracted |
| -> Array a | will contain the variance of the input array along dimension dim |
Calculates variance of Array along user-specified dimension.
>>>var (vector @Double 8 [1..8]) Population 0ArrayFire Array [1 1 1 1] 5.2500
data VarianceType Source #
Data type used to express variance type in the var function
Constructors
| Population | |
| Sample |
Instances
| Enum VarianceType Source # | |
Defined in ArrayFire.Statistics Methods succ :: VarianceType -> VarianceType # pred :: VarianceType -> VarianceType # toEnum :: Int -> VarianceType # fromEnum :: VarianceType -> Int # enumFrom :: VarianceType -> [VarianceType] # enumFromThen :: VarianceType -> VarianceType -> [VarianceType] # enumFromTo :: VarianceType -> VarianceType -> [VarianceType] # enumFromThenTo :: VarianceType -> VarianceType -> VarianceType -> [VarianceType] # | |
| Show VarianceType Source # | |
Defined in ArrayFire.Statistics Methods showsPrec :: Int -> VarianceType -> ShowS # show :: VarianceType -> String # showList :: [VarianceType] -> ShowS # | |
| Eq VarianceType Source # | |
Defined in ArrayFire.Statistics | |
Arguments
| :: (AFType a, Fractional a) | |
| => Array a | Input |
| -> Array a | Weights |
| -> Int | The dimension along which the variance is extracted |
| -> Array a | Contains the variance of the input array along dimension dim |
Calculates varWeighted of Array along user-specified dimension.
>>>varWeighted (vector @Double 10 [1..]) (vector @Double 10 [1..]) 0ArrayFire Array [1 1 1 1] 1.9091
Arguments
| :: (AFType a, Fractional a) | |
| => Array a | First input |
| -> Array a | Second input |
| -> Bool | A boolean specifying if biased estimate should be taken (default: |
| -> Array a | Contains will the covariance of the input |
Calculates covariance of two Arrays with a bias specifier.
>>>cov (vector @Double 10 (repeat 1)) (vector @Double 10 (repeat 1)) FalseArrayFire Array [1 1 1 1] 0.0000
Calculates weighted mean of all elements in an Array
>>>meanAllWeighted (matrix @Double (2,2) [[1,2],[3,4]]) (matrix @Double (2,2) [[1,2],[3,4]])2.8181818181818183
Arguments
| :: AFResult a | |
| => Array a | Input |
| -> VarianceType |
|
| -> Scalar a | Variance of all elements |
Calculates variance of all elements in an Array
>>>varAll (vector @Double 10 (repeat 10)) Population0.0
Arguments
| :: AFResult a | |
| => Array a | Input |
| -> Array a |
|
| -> Scalar a | Weighted variance of all elements |
Calculates weighted variance of all elements in an Array
>>>varAllWeighted ( vector @Double 10 [1..] ) ( vector @Double 10 [1..] )6.011479591836735
Calculates standard deviation of all elements in an Array
>>>stdevAll (vector @Double 10 (repeat 10))0.0
Calculates median of all elements in an Array
>>>medianAll (vector @Double 10 (repeat 10))10.0
Arguments
| :: AFResult a | |
| => Array a | First input |
| -> Array a | Second input |
| -> Scalar a | Correlation coefficient |
This algorithm returns Pearson product-moment correlation coefficient. https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
>>>corrCoef ( vector @Int 10 [1..] ) ( vector @Int 10 [10,9..] )-1.0
Arguments
| :: AFType a | |
| => Array a | First input |
| -> Int | The number of elements to be retrieved along the dim dimension |
| -> TopK | If descending, the highest values are returned. Otherwise, the lowest values are returned |
| -> (Array a, Array Word32) | Returns The values of the top k elements along the dim dimension along with the indices of the top k elements along the dim dimension |
This function returns the top k values along a given dimension of the input array.
>>> let (vals,indexes) =topk(vector@Double10 [1..] ) 3TopKDefault>>> indexes ArrayFire Array [3 1 1 1] 9 8 7 >>> vals ArrayFire Array [3 1 1 1] 10.0000 9.0000 8.0000
The indices along with their values are returned. If the input is a multi-dimensional array, the indices will be the index of the value in that dimension. Order of duplicate values are not preserved. This function is optimized for small values of k. This function performs the operation across all dimensions of the input array. This function is optimized for small values of k. The order of the returned keys may not be in the same order as the appear in the input array
Arguments
| :: (AFType a, Fractional a) | |
| => Array a | Input |
| -> VarBias | Variance bias correction: |
| -> Int | Dimension along which to compute |
| -> (Array a, Array a) | (mean, variance) |
Arguments
| :: (AFType a, Fractional a) | |
| => Array a | Input |
| -> Array a | Weights |
| -> VarBias | Variance bias correction |
| -> Int | Dimension along which to compute |
| -> (Array a, Array a) | (mean, variance) |
Simultaneously compute the weighted mean and variance of an Array along a dimension.
>>>let (m, v) = meanVarWeighted (vector @Double 4 [1,2,3,4]) (vector @Double 4 [1,1,1,1]) VariancePopulation 0>>>mArrayFire Array [1 1 1 1] 2.5000