diff --git a/src/cov.jl b/src/cov.jl index 5ada1a5b5..b882399e2 100644 --- a/src/cov.jl +++ b/src/cov.jl @@ -123,6 +123,11 @@ Compute the Pearson correlation matrix of `X` along the dimension cor(x::AbstractMatrix, w::AbstractWeights, dims::Int=1) = corm(x, mean(x, w, dims=dims), w, dims) +function mean_and_cov(x::AbstractVector; corrected::Bool=true) + m = mean(x) + return m, covm(x, m, corrected=corrected) +end + function mean_and_cov(x::AbstractMatrix, dims::Int=1; corrected::Bool=true) m = mean(x, dims=dims) return m, covm(x, m, dims, corrected=corrected) @@ -133,11 +138,6 @@ function mean_and_cov(x::AbstractMatrix, wv::AbstractWeights, dims::Int=1; return m, cov(x, wv, dims; corrected=depcheck(:mean_and_cov, corrected)) end -function mean_and_cov(x::AbstractVector; corrected::Bool=true) - m = mean(x) - return m, covm(x, m, corrected=corrected) -end - """ cov2cor(C, s) diff --git a/test/cov.jl b/test/cov.jl index e45c56879..b12f71032 100644 --- a/test/cov.jl +++ b/test/cov.jl @@ -137,7 +137,6 @@ sparse_array = sprandn(3, 8, 0.2) cor1 = cor(X, wv1, 1) cor2 = cor(X, wv2, 2) - @testset "cov2cor" begin @test cov2cor(cov(X, dims = 1), std(X, dims = 1)) ≈ₙ cor(X, dims = 1) @test cov2cor(cov(X, dims = 2), std(X, dims = 2)) ≈ₙ cor(X, dims = 2)