@@ -3513,13 +3513,13 @@ def mean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, *,
3513
3513
3514
3514
3515
3515
def _std_dispatcher (a , axis = None , dtype = None , out = None , ddof = None ,
3516
- keepdims = None , * , where = None , mean = None ):
3516
+ keepdims = None , * , where = None , mean = None , correction = None ):
3517
3517
return (a , where , out , mean )
3518
3518
3519
3519
3520
3520
@array_function_dispatch (_std_dispatcher )
3521
3521
def std (a , axis = None , dtype = None , out = None , ddof = 0 , keepdims = np ._NoValue , * ,
3522
- where = np ._NoValue , mean = np ._NoValue ):
3522
+ where = np ._NoValue , mean = np ._NoValue , correction = 0 ):
3523
3523
"""
3524
3524
Compute the standard deviation along the specified axis.
3525
3525
@@ -3567,14 +3567,20 @@ def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *,
3567
3567
3568
3568
.. versionadded:: 1.20.0
3569
3569
3570
- mean : array like , optional
3570
+ mean : array_like , optional
3571
3571
Provide the mean to prevent its recalculation. The mean should have
3572
3572
a shape as if it was calculated with ``keepdims=True``.
3573
3573
The axis for the calculation of the mean should be the same as used in
3574
3574
the call to this std function.
3575
3575
3576
3576
.. versionadded:: 1.26.0
3577
3577
3578
+ correction : int, optional
3579
+ Array API compatible name for the ``ddof`` parameter. Only one of them
3580
+ can be provided at the same time.
3581
+
3582
+ .. versionadded:: 2.0.0
3583
+
3578
3584
Returns
3579
3585
-------
3580
3586
standard_deviation : ndarray, see dtype parameter above.
@@ -3666,6 +3672,14 @@ def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *,
3666
3672
if mean is not np ._NoValue :
3667
3673
kwargs ['mean' ] = mean
3668
3674
3675
+ if correction != 0 :
3676
+ if ddof != 0 :
3677
+ raise ValueError (
3678
+ "ddof and correction can't be provided simultaneously."
3679
+ )
3680
+ else :
3681
+ ddof = correction
3682
+
3669
3683
if type (a ) is not mu .ndarray :
3670
3684
try :
3671
3685
std = a .std
@@ -3679,13 +3693,13 @@ def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *,
3679
3693
3680
3694
3681
3695
def _var_dispatcher (a , axis = None , dtype = None , out = None , ddof = None ,
3682
- keepdims = None , * , where = None , mean = None ):
3696
+ keepdims = None , * , where = None , mean = None , correction = None ):
3683
3697
return (a , where , out , mean )
3684
3698
3685
3699
3686
3700
@array_function_dispatch (_var_dispatcher )
3687
3701
def var (a , axis = None , dtype = None , out = None , ddof = 0 , keepdims = np ._NoValue , * ,
3688
- where = np ._NoValue , mean = np ._NoValue ):
3702
+ where = np ._NoValue , mean = np ._NoValue , correction = 0 ):
3689
3703
"""
3690
3704
Compute the variance along the specified axis.
3691
3705
@@ -3742,6 +3756,12 @@ def var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *,
3742
3756
3743
3757
.. versionadded:: 1.26.0
3744
3758
3759
+ correction : int, optional
3760
+ Array API compatible name for the ``ddof`` parameter. Only one of them
3761
+ can be provided at the same time.
3762
+
3763
+ .. versionadded:: 2.0.0
3764
+
3745
3765
Returns
3746
3766
-------
3747
3767
variance : ndarray, see dtype parameter above
@@ -3832,6 +3852,14 @@ def var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *,
3832
3852
if mean is not np ._NoValue :
3833
3853
kwargs ['mean' ] = mean
3834
3854
3855
+ if correction != 0 :
3856
+ if ddof != 0 :
3857
+ raise ValueError (
3858
+ "ddof and correction can't be provided simultaneously."
3859
+ )
3860
+ else :
3861
+ ddof = correction
3862
+
3835
3863
if type (a ) is not mu .ndarray :
3836
3864
try :
3837
3865
var = a .var
0 commit comments