@@ -59,7 +59,7 @@ def mean(a, weights=None, dim=None):
5959
6060 return real if imag == 0 else real + imag * 1j
6161
62- def var (a , isbiased = False , weights = None , dim = None ):
62+ def var (a , bias = VARIANCE . DEFAULT , weights = None , dim = None ):
6363 """
6464 Calculate variance along a given dimension.
6565
@@ -68,9 +68,9 @@ def var(a, isbiased=False, weights=None, dim=None):
6868 a: af.Array
6969 The input array.
7070
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 .
7474
7575 weights: optional: af.Array. default: None.
7676 Array to calculate for the weighted mean. Must match size of
@@ -89,7 +89,7 @@ def var(a, isbiased=False, weights=None, dim=None):
8989 out = Array ()
9090
9191 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 )))
9393 else :
9494 safe_call (backend .get ().af_var_weighted (c_pointer (out .arr ), a .arr , weights .arr , c_int_t (dim )))
9595
@@ -99,7 +99,7 @@ def var(a, isbiased=False, weights=None, dim=None):
9999 imag = c_double_t (0 )
100100
101101 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 ))
103103 else :
104104 safe_call (backend .get ().af_var_all_weighted (c_pointer (real ), c_pointer (imag ), a .arr , weights .arr ))
105105
@@ -150,7 +150,7 @@ def meanvar(a, weights=None, bias=VARIANCE.DEFAULT, dim=-1):
150150 return mean_out , var_out
151151
152152
153- def stdev (a , dim = None ):
153+ def stdev (a , bias = VARIANCE . DEFAULT , dim = None ):
154154 """
155155 Calculate standard deviation along a given dimension.
156156
@@ -159,6 +159,10 @@ def stdev(a, dim=None):
159159 a: af.Array
160160 The input array.
161161
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+
162166 dim: optional: int. default: None.
163167 The dimension for which to obtain the standard deviation from
164168 input data.
@@ -171,48 +175,41 @@ def stdev(a, dim=None):
171175 """
172176 if dim is not None :
173177 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 )))
175180 return out
176181 else :
177182 real = c_double_t (0 )
178183 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 ))
180186 real = real .value
181187 imag = imag .value
182188 return real if imag == 0 else real + imag * 1j
183189
184- def cov (a , isbiased = False , dim = None ):
190+ def cov (a , b , bias = VARIANCE . DEFAULT ):
185191 """
186192 Calculate covariance along a given dimension.
187193
188194 Parameters
189195 ----------
190196 a: af.Array
191- The input array.
197+ Input array.
192198
193- isbiased: optional: Boolean. default: False.
194- Boolean denoting whether biased estimate should be taken .
199+ b: af.Array
200+ Input array .
195201
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) .
198204
199205 Returns
200206 -------
201207 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.
204209 """
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
216213
217214def median (a , dim = None ):
218215 """
0 commit comments