@@ -59,7 +59,7 @@ def mean(a, weights=None, dim=None):
59
59
60
60
return real if imag == 0 else real + imag * 1j
61
61
62
- def var (a , isbiased = False , weights = None , dim = None ):
62
+ def var (a , bias = VARIANCE . DEFAULT , weights = None , dim = None ):
63
63
"""
64
64
Calculate variance along a given dimension.
65
65
@@ -68,9 +68,9 @@ def var(a, isbiased=False, weights=None, dim=None):
68
68
a: af.Array
69
69
The input array.
70
70
71
- isbiased : optional: Boolean. default: False .
72
- Boolean denoting population variance (false ) or sample
73
- variance (true) .
71
+ bias : optional: af.VARIANCE. default: DEFAULT .
72
+ population variance(VARIANCE.POPULATION ) or sample variance(VARIANCE.SAMPLE).
73
+ This is ignored if weights are provided .
74
74
75
75
weights: optional: af.Array. default: None.
76
76
Array to calculate for the weighted mean. Must match size of
@@ -89,7 +89,7 @@ def var(a, isbiased=False, weights=None, dim=None):
89
89
out = Array ()
90
90
91
91
if weights is None :
92
- safe_call (backend .get ().af_var (c_pointer (out .arr ), a .arr , isbiased , c_int_t (dim )))
92
+ safe_call (backend .get ().af_var_v2 (c_pointer (out .arr ), a .arr , bias . value , c_int_t (dim )))
93
93
else :
94
94
safe_call (backend .get ().af_var_weighted (c_pointer (out .arr ), a .arr , weights .arr , c_int_t (dim )))
95
95
@@ -99,7 +99,7 @@ def var(a, isbiased=False, weights=None, dim=None):
99
99
imag = c_double_t (0 )
100
100
101
101
if weights is None :
102
- safe_call (backend .get ().af_var_all (c_pointer (real ), c_pointer (imag ), a .arr , isbiased ))
102
+ safe_call (backend .get ().af_var_all_v2 (c_pointer (real ), c_pointer (imag ), a .arr , bias . value ))
103
103
else :
104
104
safe_call (backend .get ().af_var_all_weighted (c_pointer (real ), c_pointer (imag ), a .arr , weights .arr ))
105
105
@@ -150,7 +150,7 @@ def meanvar(a, weights=None, bias=VARIANCE.DEFAULT, dim=-1):
150
150
return mean_out , var_out
151
151
152
152
153
- def stdev (a , dim = None ):
153
+ def stdev (a , bias = VARIANCE . DEFAULT , dim = None ):
154
154
"""
155
155
Calculate standard deviation along a given dimension.
156
156
@@ -159,6 +159,10 @@ def stdev(a, dim=None):
159
159
a: af.Array
160
160
The input array.
161
161
162
+ bias: optional: af.VARIANCE. default: DEFAULT.
163
+ population variance(VARIANCE.POPULATION) or sample variance(VARIANCE.SAMPLE).
164
+ This is ignored if weights are provided.
165
+
162
166
dim: optional: int. default: None.
163
167
The dimension for which to obtain the standard deviation from
164
168
input data.
@@ -171,48 +175,41 @@ def stdev(a, dim=None):
171
175
"""
172
176
if dim is not None :
173
177
out = Array ()
174
- safe_call (backend .get ().af_stdev (c_pointer (out .arr ), a .arr , c_int_t (dim )))
178
+ safe_call (backend .get ().af_stdev_v2 (c_pointer (out .arr ), a .arr , bias .value ,
179
+ c_int_t (dim )))
175
180
return out
176
181
else :
177
182
real = c_double_t (0 )
178
183
imag = c_double_t (0 )
179
- safe_call (backend .get ().af_stdev_all (c_pointer (real ), c_pointer (imag ), a .arr ))
184
+ safe_call (backend .get ().af_stdev_all_v2 (c_pointer (real ), c_pointer (imag ), a .arr ,
185
+ bias .value ))
180
186
real = real .value
181
187
imag = imag .value
182
188
return real if imag == 0 else real + imag * 1j
183
189
184
- def cov (a , isbiased = False , dim = None ):
190
+ def cov (a , b , bias = VARIANCE . DEFAULT ):
185
191
"""
186
192
Calculate covariance along a given dimension.
187
193
188
194
Parameters
189
195
----------
190
196
a: af.Array
191
- The input array.
197
+ Input array.
192
198
193
- isbiased: optional: Boolean. default: False.
194
- Boolean denoting whether biased estimate should be taken .
199
+ b: af.Array
200
+ Input array .
195
201
196
- dim : optional: int. default: None .
197
- The dimension for which to obtain the covariance from input data .
202
+ bias : optional: af.VARIANCE. default: DEFAULT .
203
+ population variance(VARIANCE.POPULATION) or sample variance(VARIANCE.SAMPLE) .
198
204
199
205
Returns
200
206
-------
201
207
output: af.Array
202
- Array containing the covariance of the input array along a
203
- given dimension.
208
+ Array containing the covariance of the input array along a given dimension.
204
209
"""
205
- if dim is not None :
206
- out = Array ()
207
- safe_call (backend .get ().af_cov (c_pointer (out .arr ), a .arr , isbiased , c_int_t (dim )))
208
- return out
209
- else :
210
- real = c_double_t (0 )
211
- imag = c_double_t (0 )
212
- safe_call (backend .get ().af_cov_all (c_pointer (real ), c_pointer (imag ), a .arr , isbiased ))
213
- real = real .value
214
- imag = imag .value
215
- return real if imag == 0 else real + imag * 1j
210
+ out = Array ()
211
+ safe_call (backend .get ().af_cov_v2 (c_pointer (out .arr ), a .arr , b .arr , bias .value ))
212
+ return out
216
213
217
214
def median (a , dim = None ):
218
215
"""
0 commit comments