I'm trying to use mean(A,1)
to get the mean row of a matrix A
, but am getting an error.
For example, try running the command mean(eye(3), 1)
.
This gives the error no method mean(Array{Float64,2},Int32)
.
The only documentation I can find for the mean
function is here:
http://docs.julialang.org/en/release-0.1/stdlib/base/#statistics
mean(v[, region])
Compute the mean of whole array
v
, or optionally along the dimensions inregion
.
What is the region
parameter?
EDIT: for Julia 0.7 and higher, write this as mean(v, dims=1)
.
julia> using Statistics
julia> A = [[1 2 3];[ 4 5 6]]
2×3 Array{Int64,2}:
1 2 3
4 5 6
# Column means
julia> mean(A, dims=1)
1×3 Array{Float64,2}:
2.5 3.5 4.5
# Row means
julia> mean(A, dims=2)
2×1 Array{Float64,2}:
2.0
5.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With