diff --git a/Project.toml b/Project.toml index 4195753a..33a18638 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "StatsBase" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" authors = ["JuliaStats"] -version = "0.34.4" +version = "0.35.0" [deps] AliasTables = "66dad0bd-aa9a-41b7-9441-69ab47430ed8" diff --git a/src/deprecates.jl b/src/deprecates.jl index 0b2a7328..4480ed0e 100644 --- a/src/deprecates.jl +++ b/src/deprecates.jl @@ -13,10 +13,6 @@ end @deprecate norepeats(a::AbstractArray) allunique(a) -@deprecate(mad!(v::AbstractArray{<:Real}, center; - constant::Real = BigFloat("1.482602218505601860547076529360423431326703202590312896536266275245674447622701")), - mad!(v, center=center, constant=constant)) - ### Deprecated January 2019 @deprecate scattermatm(x::DenseMatrix, mean, dims::Int) scattermat(x, mean=mean, dims=dims) @deprecate scattermatm(x::DenseMatrix, mean, wv::AbstractWeights, dims::Int) scattermat(x, wv, mean=mean, dims=dims) diff --git a/src/scalarstats.jl b/src/scalarstats.jl index 4c509c41..39d5ef02 100644 --- a/src/scalarstats.jl +++ b/src/scalarstats.jl @@ -524,10 +524,10 @@ function sem(x::AbstractArray, weights::ProbabilityWeights; mean=nothing) end # Median absolute deviation -@irrational mad_constant 1.4826022185056018 BigFloat("1.482602218505601860547076529360423431326703202590312896536266275245674447622701") +@irrational mad_to_std_multiplier 1.4826022185056018 BigFloat("1.482602218505601860547076529360423431326703202590312896536266275245674447622701") """ - mad(x; center=median(x), normalize=true) + mad(x; center=median(x), normalize=false) Compute the median absolute deviation (MAD) of collection `x` around `center` (by default, around the median). @@ -536,12 +536,12 @@ If `normalize` is set to `true`, the MAD is multiplied by `1 / quantile(Normal(), 3/4) ≈ 1.4826`, in order to obtain a consistent estimator of the standard deviation under the assumption that the data is normally distributed. """ -function mad(x; center=nothing, normalize::Union{Bool, Nothing}=nothing, constant=nothing) - mad!(Base.copymutable(x); center=center, normalize=normalize, constant=constant) +function mad(x; center=nothing, normalize::Union{Bool, Nothing}=nothing) + mad!(Base.copymutable(x); center=center, normalize=normalize) end """ - StatsBase.mad!(x; center=median!(x), normalize=true) + StatsBase.mad!(x; center=median!(x), normalize=false) Compute the median absolute deviation (MAD) of array `x` around `center` (by default, around the median), overwriting `x` in the process. @@ -552,8 +552,7 @@ of the standard deviation under the assumption that the data is normally distrib """ function mad!(x::AbstractArray; center=median!(x), - normalize::Union{Bool,Nothing}=true, - constant=nothing) + normalize::Union{Bool,Nothing}=false) isempty(x) && throw(ArgumentError("mad is not defined for empty arrays")) c = center === nothing ? median!(x) : center T = promote_type(typeof(c), eltype(x)) @@ -561,15 +560,8 @@ function mad!(x::AbstractArray; x2 = U == T ? x : isconcretetype(U) && isconcretetype(T) && sizeof(U) == sizeof(T) ? reinterpret(T, x) : similar(x, T) x2 .= abs.(x .- c) m = median!(x2) - if normalize isa Nothing - Base.depwarn("the `normalize` keyword argument will be false by default in future releases: set it explicitly to silence this deprecation", :mad) - normalize = true - end - if !isa(constant, Nothing) - Base.depwarn("keyword argument `constant` is deprecated, use `normalize` instead or apply the multiplication directly", :mad) - m * constant - elseif normalize - m * mad_constant + if normalize === true + m * mad_to_std_multiplier else m end