Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor var/varm #17

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix
  • Loading branch information
yuehhua committed Dec 12, 2019
commit 1fd4d7a6828d86c3bed0e1358512c3fc075247c0
6 changes: 3 additions & 3 deletions src/Statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function _var(iterable, corrected::Bool, ::Nothing)
S = S + realXcY(value - M, value - new_M)
M = new_M
end
return S / (count - Int(corrected))
return S / (count - corrected)
end

function _var(iterable, corrected::Bool, mean::Number)
Expand All @@ -212,14 +212,14 @@ function _var(iterable, corrected::Bool, mean::Number)
count = 1
value, state = y
y = iterate(iterable, state)
sum2 = abs2(value - mean::Number)
sum2 = abs2(value - mean)
while y !== nothing
value, state = y
y = iterate(iterable, state)
count += 1
sum2 += abs2(value - mean)
end
return sum2 / (count - Int(corrected))
return sum2 / (count - corrected)
end

centralizedabs2fun(m) = x -> abs2.(x - m)
Expand Down