@@ -524,10 +524,10 @@ function sem(x::AbstractArray, weights::ProbabilityWeights; mean=nothing)
524524end
525525
526526# Median absolute deviation
527- @irrational mad_constant 1.4826022185056018 BigFloat (" 1.482602218505601860547076529360423431326703202590312896536266275245674447622701" )
527+ @irrational mad_to_std_multiplier 1.4826022185056018 BigFloat (" 1.482602218505601860547076529360423431326703202590312896536266275245674447622701" )
528528
529529"""
530- mad(x; center=median(x), normalize=true )
530+ mad(x; center=median(x), normalize=false )
531531
532532Compute the median absolute deviation (MAD) of collection `x` around `center`
533533(by default, around the median).
@@ -536,12 +536,12 @@ If `normalize` is set to `true`, the MAD is multiplied by
536536`1 / quantile(Normal(), 3/4) ≈ 1.4826`, in order to obtain a consistent estimator
537537of the standard deviation under the assumption that the data is normally distributed.
538538"""
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)
541541end
542542
543543"""
544- StatsBase.mad!(x; center=median!(x), normalize=true )
544+ StatsBase.mad!(x; center=median!(x), normalize=false )
545545
546546Compute the median absolute deviation (MAD) of array `x` around `center`
547547(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
552552"""
553553function mad! (x:: AbstractArray ;
554554 center= median! (x),
555- normalize:: Union{Bool,Nothing} = true ,
556- constant= nothing )
555+ normalize:: Union{Bool,Nothing} = false )
557556 isempty (x) && throw (ArgumentError (" mad is not defined for empty arrays" ))
558557 c = center === nothing ? median! (x) : center
559558 T = promote_type (typeof (c), eltype (x))
560559 U = eltype (x)
561560 x2 = U == T ? x : isconcretetype (U) && isconcretetype (T) && sizeof (U) == sizeof (T) ? reinterpret (T, x) : similar (x, T)
562561 x2 .= abs .(x .- c)
563562 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
573565 else
574566 m
575567 end
0 commit comments