@@ -37,14 +37,10 @@ import ArrayFire.Internal.Types
37
37
38
38
-- | Calculates 'mean' of 'Array' along user-specified dimension.
39
39
--
40
- -- @
41
- -- >>> print $ mean 0 ( vector @Int 10 [1..] )
42
- -- @
43
- -- @
40
+ -- >>> mean 0 ( vector @Int 10 [1..] )
44
41
-- ArrayFire Array
45
42
-- [1 1 1 1]
46
43
-- 5.5000
47
- -- @
48
44
mean
49
45
:: AFType a
50
46
=> Array a
@@ -59,14 +55,10 @@ mean a n =
59
55
60
56
-- | Calculates 'meanWeighted' of 'Array' along user-specified dimension.
61
57
--
62
- -- @
63
- -- >>> print $ meanWeighted (vector @Double 10 [1..10]) (vector @Double 10 [1..10]) 0
64
- -- @
65
- -- @
58
+ -- >>> meanWeighted (vector @Double 10 [1..10]) (vector @Double 10 [1..10]) 0
66
59
-- ArrayFire Array
67
60
-- [1 1 1 1]
68
61
-- 7.0000
69
- -- @
70
62
meanWeighted
71
63
:: AFType a
72
64
=> Array a
@@ -83,14 +75,10 @@ meanWeighted x y (fromIntegral -> n) =
83
75
84
76
-- | Calculates 'variance' of 'Array' along user-specified dimension.
85
77
--
86
- -- @
87
- -- >>> print $ var (vector @Double 8 [1..8]) False 0
88
- -- @
89
- -- @
78
+ -- >>> var (vector @Double 8 [1..8]) False 0
90
79
-- ArrayFire Array
91
80
-- [1 1 1 1]
92
81
-- 6.0
93
- -- @
94
82
var
95
83
:: AFType a
96
84
=> Array a
@@ -107,14 +95,10 @@ var arr (fromIntegral . fromEnum -> b) d =
107
95
108
96
-- | Calculates 'varWeighted' of 'Array' along user-specified dimension.
109
97
--
110
- -- @
111
- -- >>> print $ varWeighted 0 ( vector @Int 10 [1..] ) ( vector @Int 10 [1..] )
112
- -- @
113
- -- @
98
+ -- >>> varWeighted 0 ( vector @Int 10 [1..] ) ( vector @Int 10 [1..] )
114
99
-- ArrayFire Array
115
100
-- [1 1 1 1]
116
101
-- 5.5000
117
- -- @
118
102
varWeighted
119
103
:: AFType a
120
104
=> Array a
@@ -131,14 +115,10 @@ varWeighted x y (fromIntegral -> n) =
131
115
132
116
-- | Calculates 'stdev' of 'Array' along user-specified dimension.
133
117
--
134
- -- @
135
118
-- >>> stdev (vector @Double 10 (cycle [1,-1])) 0
136
- -- @
137
- -- @
138
119
-- ArrayFire Array
139
120
-- [1 1 1 1]
140
121
-- 1.0
141
- -- @
142
122
stdev
143
123
:: AFType a
144
124
=> Array a
@@ -153,14 +133,10 @@ stdev a n =
153
133
154
134
-- | Calculates 'covariance' two 'Array's with a bias specifier.
155
135
--
156
- -- @
157
- -- >>> print $ cov (vector @Double 10 (repeat 1)) (vector @Double 10 (repeat 1)) False
158
- -- @
159
- -- @
136
+ -- >>> cov (vector @Double 10 (repeat 1)) (vector @Double 10 (repeat 1)) False
160
137
-- ArrayFire Array
161
138
-- [1 1 1 1]
162
139
-- 0.0
163
- -- @
164
140
cov
165
141
:: AFType a
166
142
=> Array a
@@ -177,14 +153,10 @@ cov x y (fromIntegral . fromEnum -> n) =
177
153
178
154
-- | Calculates 'median' of 'Array' along user-specified dimension.
179
155
--
180
- -- @
181
156
-- >>> print $ median ( vector @Int 10 [1..] ) 0
182
- -- @
183
- -- @
184
157
-- ArrayFire Array
185
158
-- [1 1 1 1]
186
159
-- 5.5000
187
- -- @
188
160
median
189
161
:: AFType a
190
162
=> Array a
@@ -199,12 +171,8 @@ median a n =
199
171
200
172
-- | Calculates 'mean' of all elements in an 'Array'
201
173
--
202
- -- @
203
- -- >>> print $ fst (meanAll (matrix @Double (2,2) (repeat 10)))
204
- -- @
205
- -- @
206
- -- >>> 10.0
207
- -- @
174
+ -- >>> fst (meanAll (matrix @Double (2,2) (repeat 10)))
175
+ -- 10.0
208
176
meanAll
209
177
:: AFType a
210
178
=> Array a
@@ -215,12 +183,8 @@ meanAll = (`infoFromArray2` af_mean_all)
215
183
216
184
-- | Calculates weighted mean of all elements in an 'Array'
217
185
--
218
- -- @
219
186
-- >>> print $ fst (meanAllWeighted (matrix @Double (2,2) (repeat 10)) (matrix @Double (2,2) (repeat 0)))
220
- -- @
221
- -- @
222
187
-- 10
223
- -- @
224
188
meanAllWeighted
225
189
:: AFType a
226
190
=> Array a
@@ -234,12 +198,8 @@ meanAllWeighted a b =
234
198
235
199
-- | Calculates variance of all elements in an 'Array'
236
200
--
237
- -- @
238
- -- >>> print $ fst (varAll (vector @Double 10 (repeat 10)) False)
239
- -- @
240
- -- @
201
+ -- >>> fst (varAll (vector @Double 10 (repeat 10)) False)
241
202
-- 0
242
- -- @
243
203
varAll
244
204
:: AFType a
245
205
=> Array a
@@ -254,12 +214,8 @@ varAll a (fromIntegral . fromEnum -> b) =
254
214
255
215
-- | Calculates weighted variance of all elements in an 'Array'
256
216
--
257
- -- @
258
- -- >>> print $ varAllWeighted ( vector @Int 10 [1..] ) ( vector @Int 10 [1..] )
259
- -- @
260
- -- @
217
+ -- >>> varAllWeighted ( vector @Int 10 [1..] ) ( vector @Int 10 [1..] )
261
218
-- 0
262
- -- @
263
219
varAllWeighted
264
220
:: AFType a
265
221
=> Array a
@@ -273,12 +229,8 @@ varAllWeighted a b =
273
229
274
230
-- | Calculates standard deviation of all elements in an 'Array'
275
231
--
276
- -- @
277
- -- >>> print $ fst (stdevAll (vector @Double 10 (repeat 10)))
278
- -- @
279
- -- @
232
+ -- >>> fst (stdevAll (vector @Double 10 (repeat 10)))
280
233
-- 10
281
- -- @
282
234
stdevAll
283
235
:: AFType a
284
236
=> Array a
@@ -289,12 +241,8 @@ stdevAll = (`infoFromArray2` af_stdev_all)
289
241
290
242
-- | Calculates median of all elements in an 'Array'
291
243
--
292
- -- @
293
- -- >>> print $ fst (medianAll (vector @Double 10 (repeat 10)))
294
- -- @
295
- -- @
244
+ -- >>> fst (medianAll (vector @Double 10 (repeat 10)))
296
245
-- 10
297
- -- @
298
246
medianAll
299
247
:: (AFType a , Fractional a )
300
248
=> Array a
@@ -306,12 +254,8 @@ medianAll = (`infoFromArray2` af_median_all)
306
254
-- | This algorithm returns Pearson product-moment correlation coefficient.
307
255
-- <https://en.wikipedia.org/wiki/Pearson_correlation_coefficient>
308
256
--
309
- -- @
310
- -- >>> print $ fst (corrCoef ( vector @Int 10 [1..] ) ( vector @Int 10 [10,9..] ))
311
- -- @
312
- -- @
257
+ -- >>> fst (corrCoef ( vector @Int 10 [1..] ) ( vector @Int 10 [10,9..] ))
313
258
-- -1
314
- -- @
315
259
corrCoef
316
260
:: AFType a
317
261
=> Array a
@@ -325,21 +269,17 @@ corrCoef a b =
325
269
326
270
-- | This function returns the top k values along a given dimension of the input array.
327
271
--
328
- -- @
329
272
-- >>> let (vals,indexes) = 'topk' ( 'vector' \@'Double' 10 [1..] ) 3 'TopKDefault'
330
- -- >>> print vals
331
273
-- >>> print indexes
332
- -- @
333
- -- @
274
+ --
334
275
-- ArrayFire 'Array'
335
276
-- [3 1 1 1]
336
277
-- 10.0000 9.0000 8.0000
337
- -- @
338
- -- @
278
+ --
279
+ -- >>> print vals
339
280
-- ArrayFire 'Array'
340
281
-- [3 1 1 1]
341
282
-- 9 8 7
342
- -- @
343
283
--
344
284
-- 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.
345
285
-- This function performs the operation across all dimensions of the input array.
0 commit comments