15
15
from .array import *
16
16
17
17
def mean (a , weights = None , dim = None ):
18
+ """
19
+ Calculate mean along a given dimension.
20
+
21
+ Parameters
22
+ ----------
23
+ a: af.Array
24
+ The input array.
25
+
26
+ weights: optional: af.Array. default: None.
27
+ Array to calculate the weighted mean. Must match size of the
28
+ input array.
29
+
30
+ dim: optional: int. default: None.
31
+ The dimension for which to obtain the mean from input data.
32
+
33
+ Returns
34
+ -------
35
+ output: af.Array
36
+ Array containing the mean of the input array along a given
37
+ dimension.
38
+ """
18
39
if dim is not None :
19
40
out = Array ()
20
41
@@ -39,6 +60,31 @@ def mean(a, weights=None, dim=None):
39
60
return real if imag == 0 else real + imag * 1j
40
61
41
62
def var (a , isbiased = False , weights = None , dim = None ):
63
+ """
64
+ Calculate variance along a given dimension.
65
+
66
+ Parameters
67
+ ----------
68
+ a: af.Array
69
+ The input array.
70
+
71
+ isbiased: optional: Boolean. default: False.
72
+ Boolean denoting population variance (false) or sample
73
+ variance (true).
74
+
75
+ weights: optional: af.Array. default: None.
76
+ Array to calculate for the weighted mean. Must match size of
77
+ the input array.
78
+
79
+ dim: optional: int. default: None.
80
+ The dimension for which to obtain the variance from input data.
81
+
82
+ Returns
83
+ -------
84
+ output: af.Array
85
+ Array containing the variance of the input array along a given
86
+ dimension.
87
+ """
42
88
if dim is not None :
43
89
out = Array ()
44
90
@@ -63,6 +109,24 @@ def var(a, isbiased=False, weights=None, dim=None):
63
109
return real if imag == 0 else real + imag * 1j
64
110
65
111
def stdev (a , dim = None ):
112
+ """
113
+ Calculate standard deviation along a given dimension.
114
+
115
+ Parameters
116
+ ----------
117
+ a: af.Array
118
+ The input array.
119
+
120
+ dim: optional: int. default: None.
121
+ The dimension for which to obtain the standard deviation from
122
+ input data.
123
+
124
+ Returns
125
+ -------
126
+ output: af.Array
127
+ Array containing the standard deviation of the input array
128
+ along a given dimension.
129
+ """
66
130
if dim is not None :
67
131
out = Array ()
68
132
safe_call (backend .get ().af_stdev (c_pointer (out .arr ), a .arr , c_int_t (dim )))
@@ -76,6 +140,26 @@ def stdev(a, dim=None):
76
140
return real if imag == 0 else real + imag * 1j
77
141
78
142
def cov (a , isbiased = False , dim = None ):
143
+ """
144
+ Calculate covariance along a given dimension.
145
+
146
+ Parameters
147
+ ----------
148
+ a: af.Array
149
+ The input array.
150
+
151
+ isbiased: optional: Boolean. default: False.
152
+ Boolean denoting whether biased estimate should be taken.
153
+
154
+ dim: optional: int. default: None.
155
+ The dimension for which to obtain the covariance from input data.
156
+
157
+ Returns
158
+ -------
159
+ output: af.Array
160
+ Array containing the covariance of the input array along a
161
+ given dimension.
162
+ """
79
163
if dim is not None :
80
164
out = Array ()
81
165
safe_call (backend .get ().af_cov (c_pointer (out .arr ), a .arr , isbiased , c_int_t (dim )))
@@ -89,6 +173,23 @@ def cov(a, isbiased=False, dim=None):
89
173
return real if imag == 0 else real + imag * 1j
90
174
91
175
def median (a , dim = None ):
176
+ """
177
+ Calculate median along a given dimension.
178
+
179
+ Parameters
180
+ ----------
181
+ a: af.Array
182
+ The input array.
183
+
184
+ dim: optional: int. default: None.
185
+ The dimension for which to obtain the median from input data.
186
+
187
+ Returns
188
+ -------
189
+ output: af.Array
190
+ Array containing the median of the input array along a
191
+ given dimension.
192
+ """
92
193
if dim is not None :
93
194
out = Array ()
94
195
safe_call (backend .get ().af_median (c_pointer (out .arr ), a .arr , c_int_t (dim )))
@@ -102,6 +203,22 @@ def median(a, dim=None):
102
203
return real if imag == 0 else real + imag * 1j
103
204
104
205
def corrcoef (x , y ):
206
+ """
207
+ Calculate the correlation coefficient of the input arrays.
208
+
209
+ Parameters
210
+ ----------
211
+ x: af.Array
212
+ The first input array.
213
+
214
+ y: af.Array
215
+ The second input array.
216
+
217
+ Returns
218
+ -------
219
+ output: af.Array
220
+ Array containing the correlation coefficient of the input arrays.
221
+ """
105
222
real = c_double_t (0 )
106
223
imag = c_double_t (0 )
107
224
safe_call (backend .get ().af_corrcoef (c_pointer (real ), c_pointer (imag ), x .arr , y .arr ))
0 commit comments