Skip to content

Commit

Permalink
added version of entropy for ::SparseVector
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-asmar committed Jul 22, 2024
1 parent 105284d commit 4c5b380
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,14 @@ function entropy(b::AbstractVector)
return ent
end

function entropy(b::SparseVector)
ent = 0.0
for b_i in b.nzval
ent -= b_i * log(b_i)
end
return ent
end

function get_interval_idx(value::Float64, lower::Float64, interval::Float64, num_intervals::Int)
if interval == 0.0
return 1
Expand Down

0 comments on commit 4c5b380

Please sign in to comment.