@@ -524,10 +524,10 @@ function sem(x::AbstractArray, weights::ProbabilityWeights; mean=nothing)
524
524
end
525
525
526
526
# Median absolute deviation
527
- @irrational mad_constant 1.4826022185056018 BigFloat (" 1.482602218505601860547076529360423431326703202590312896536266275245674447622701" )
527
+ @irrational mad_to_std_multiplier 1.4826022185056018 BigFloat (" 1.482602218505601860547076529360423431326703202590312896536266275245674447622701" )
528
528
529
529
"""
530
- mad(x; center=median(x), normalize=true )
530
+ mad(x; center=median(x), normalize=false )
531
531
532
532
Compute the median absolute deviation (MAD) of collection `x` around `center`
533
533
(by default, around the median).
@@ -536,12 +536,12 @@ If `normalize` is set to `true`, the MAD is multiplied by
536
536
`1 / quantile(Normal(), 3/4) ≈ 1.4826`, in order to obtain a consistent estimator
537
537
of the standard deviation under the assumption that the data is normally distributed.
538
538
"""
539
- function mad (x; center= nothing , normalize:: Union{Bool, Nothing} = nothing , constant = nothing )
540
- mad! (Base. copymutable (x); center= center, normalize= normalize, constant = constant )
539
+ function mad (x; center= nothing , normalize:: Union{Bool, Nothing} = nothing )
540
+ mad! (Base. copymutable (x); center= center, normalize= normalize)
541
541
end
542
542
543
543
"""
544
- StatsBase.mad!(x; center=median!(x), normalize=true )
544
+ StatsBase.mad!(x; center=median!(x), normalize=false )
545
545
546
546
Compute the median absolute deviation (MAD) of array `x` around `center`
547
547
(by default, around the median), overwriting `x` in the process.
@@ -552,24 +552,16 @@ of the standard deviation under the assumption that the data is normally distrib
552
552
"""
553
553
function mad! (x:: AbstractArray ;
554
554
center= median! (x),
555
- normalize:: Union{Bool,Nothing} = true ,
556
- constant= nothing )
555
+ normalize:: Union{Bool,Nothing} = false )
557
556
isempty (x) && throw (ArgumentError (" mad is not defined for empty arrays" ))
558
557
c = center === nothing ? median! (x) : center
559
558
T = promote_type (typeof (c), eltype (x))
560
559
U = eltype (x)
561
560
x2 = U == T ? x : isconcretetype (U) && isconcretetype (T) && sizeof (U) == sizeof (T) ? reinterpret (T, x) : similar (x, T)
562
561
x2 .= abs .(x .- c)
563
562
m = median! (x2)
564
- if normalize isa Nothing
565
- Base. depwarn (" the `normalize` keyword argument will be false by default in future releases: set it explicitly to silence this deprecation" , :mad )
566
- normalize = true
567
- end
568
- if ! isa (constant, Nothing)
569
- Base. depwarn (" keyword argument `constant` is deprecated, use `normalize` instead or apply the multiplication directly" , :mad )
570
- m * constant
571
- elseif normalize
572
- m * mad_constant
563
+ if normalize === true
564
+ m * mad_to_std_multiplier
573
565
else
574
566
m
575
567
end
0 commit comments