Skip to content

Commit

Permalink
Merge pull request #13 from StefanKarpinski/master
Browse files Browse the repository at this point in the history
median absolute deviation performance improvement
  • Loading branch information
johnmyleswhite committed Jun 12, 2013
2 parents 59008c8 + d40dc2b commit 7597c3a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Stats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ module Stats
return sv / sw
end

# median absolute deviation with known center with consistency adjustment
mad(v::AbstractArray, center::Number) = 1.4826 * median(abs(v - center))
# median absolute deviation with consistency adjustment
mad(v::AbstractArray, center::Number) = 1.4826 * median!(abs(v-center))

# median absolute deviation
mad(v::AbstractArray) = mad(v, median(v))
function mad(v::AbstractArray)
v = copy(v)
center = median!(v)
for i in 1:length(v)
v[i] = abs(v[i]-center)
end
1.4826 * median!(v, checknan=false)
end

# maximum likelihood estimate of skewness with known mean m
function skewness(v::AbstractVector, m::Number)
Expand Down

0 comments on commit 7597c3a

Please sign in to comment.