Copyright | David Johnson (c) 2019-2020 |
---|---|
License | BSD3 |
Maintainer | David Johnson <djohnson.m@gmail.com> |
Stability | Experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- mean :: AFType a => Array a -> Int -> Array a
- meanWeighted :: AFType a => Array a -> Array a -> Int -> Array a
- var :: AFType a => Array a -> Bool -> Int -> Array a
- varWeighted :: AFType a => Array a -> Array a -> Int -> Array a
- stdev :: AFType a => Array a -> Int -> Array a
- cov :: AFType a => Array a -> Array a -> Bool -> Array a
- median :: AFType a => Array a -> Int -> Array a
- meanAll :: AFType a => Array a -> (Double, Double)
- meanAllWeighted :: AFType a => Array a -> Array a -> (Double, Double)
- varAll :: AFType a => Array a -> Bool -> (Double, Double)
- varAllWeighted :: AFType a => Array a -> Array a -> (Double, Double)
- stdevAll :: AFType a => Array a -> (Double, Double)
- medianAll :: (AFType a, Fractional a) => Array a -> (Double, Double)
- corrCoef :: AFType a => Array a -> Array a -> (Double, Double)
- topk :: AFType a => Array a -> Int -> TopK -> (Array a, Array a)
Documentation
:: AFType 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]) 0
ArrayFire Array [1 1 1 1] 7.0000
:: AFType a | |
=> Array a | Input |
-> Bool | 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]) False 0
ArrayFire Array [1 1 1 1] 6.0
:: AFType 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 @Int 10 [1..] ) ( vector @Int 10 [1..] ) 0
ArrayFire Array [1 1 1 1] 5.5000
:: AFType 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 Array
s with a bias specifier.
>>>
cov (vector @Double 10 (repeat 1)) (vector @Double 10 (repeat 1)) False
ArrayFire Array [1 1 1 1] 0.0
:: AFType a | |
=> Array a | Input |
-> Array a |
|
-> (Double, Double) | Weighted mean (real and imaginary part) |
Calculates weighted mean of all elements in an Array
>>>
print $ fst (meanAllWeighted (matrix @Double (2,2) (repeat 10)) (matrix @Double (2,2) (repeat 0)))
10
:: AFType a | |
=> Array a | Input |
-> Bool | Input |
-> (Double, Double) | Variance (real and imaginary part) |
Calculates variance of all elements in an Array
>>>
fst (varAll (vector @Double 10 (repeat 10)) False)
0
:: AFType a | |
=> Array a | Input |
-> Array a |
|
-> (Double, Double) | Variance weighted result, (real and imaginary part) |
Calculates weighted variance of all elements in an Array
>>>
varAllWeighted ( vector @Int 10 [1..] ) ( vector @Int 10 [1..] )
0
:: AFType a | |
=> Array a | Input |
-> (Double, Double) | Standard deviation result, (real and imaginary part) |
Calculates standard deviation of all elements in an Array
>>>
fst (stdevAll (vector @Double 10 (repeat 10)))
10
:: (AFType a, Fractional a) | |
=> Array a | Input |
-> (Double, Double) | Median result, real and imaginary part |
Calculates median of all elements in an Array
>>>
fst (medianAll (vector @Double 10 (repeat 10)))
10
:: AFType a | |
=> Array a | First input |
-> Array a | Second input |
-> (Double, Double) | Correlation coefficient result, real and imaginary part |
This algorithm returns Pearson product-moment correlation coefficient. https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
>>>
fst (corrCoef ( vector @Int 10 [1..] ) ( vector @Int 10 [10,9..] ))
-1
:: 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 a) | 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
@Double
10 [1..] ) 3TopKDefault
>>> print indexes ArrayFireArray
[3 1 1 1] 10.0000 9.0000 8.0000 >>> print vals ArrayFireArray
[3 1 1 1] 9 8 7
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