3
votes

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 in region.

What is the region parameter?

EDIT: for Julia 0.7 and higher, write this as mean(v, dims=1).

2
It must be something with your installation, mean(eye(3),1) works just fine here.juliohm
@juliohm I have since discovered that it was something wrong with JuliaStudio (a Julia IDE) in particular. The statement works fine when run directly through julia.bat.Timothy Shields
I'll make my comment into an answer so that you can close the question.juliohm

2 Answers

5
votes
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
0
votes

It must be something with your installation, mean(eye(3),1) works just fine here.