Skip to content

Commit

Permalink
replacement of sortperm with sortperm!
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Jul 4, 2024
1 parent 9ee15ff commit 4187b82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- `depestregression` returns `Dict` instead of a `vector` of betas like other regression methods.
- `summary()` throws `ErrorException` rather than simply prompting with `@error` macro.
- `robcov` doesn't use try and catch any more.

- Replace `sortperm` with `sortperm!` in mve.

# v0.11.3

Expand Down
10 changes: 7 additions & 3 deletions src/mve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ import ..Diagnostics: mahalanobisSquaredMatrix


function enlargesubset(initialsubset, data::AbstractMatrix, h::Int)
p = size(data, 2)

n, p = size(data)

basicsubset = copy(initialsubset)

meanvector = Array{Float64}(undef, p)

md2sortedindex = Array{Int}(undef, n)

while length(basicsubset) < h
applyColumns!(meanvector, mean, data[basicsubset, :])
covmatrix = cov(data[basicsubset, :])
md2mat =
mahalanobisSquaredMatrix(data, meanvector=meanvector, covmatrix=covmatrix)
if !isnothing(md2mat)
md2 = diag(md2mat)
md2sortedindex = sortperm(md2)
#md2 = diag(md2mat)
#md2sortedindex = sortperm(md2)
sortperm!(md2sortedindex, diag(md2mat))
basicsubset = md2sortedindex[1:(length(basicsubset)+1)]
else
basicsubset = 1:(length(basicsubset)+1)
Expand Down

0 comments on commit 4187b82

Please sign in to comment.