Skip to content

Commit

Permalink
Make median behave on arrays as mean and var
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Feb 11, 2013
1 parent d3ab027 commit 87723f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function median!{T<:Real}(v::AbstractVector{T})
isnan(v[end]) && error("median is undefined in presence of NaNs")
isodd(length(v)) ? float(v[div(end+1,2)]) : (v[div(end,2)]+v[div(end,2)+1])/2
end
median{T<:Real}(v::AbstractArray{T}) = median!(copy(v))
median{T<:Real}(v::AbstractArray{T}) = median!(copy(reshape(v, length(v))))

## variance with known mean
function var(v::AbstractVector, m::Number, corrected::Bool)
Expand Down

1 comment on commit 87723f9

@StefanKarpinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. Much better, thank you.

Please sign in to comment.