Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yha committed Oct 2, 2020
1 parent 271e92c commit 1edacde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/cov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion test/cov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1edacde

Please sign in to comment.