原来的mean函数,现在改成什么了?


#1

xtrn 是一个10010018*100的四维矩阵

但是在Julia1.0中,使用mean(xtrn[:,:,1,:])函数,说mean函数没有定义。这个函数是在老版本文件中,我在跑,出错了。在文档中没有找到相关文件,请问我应该用什么函数。谢谢


#2
julia> using Statistics

julia> methods(mean)
# 5 methods for generic function "mean":
[1] mean(f::Union{Function, Type}, A::AbstractArray) in Statistics at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Statistics/src/Statistics.jl:75
[2] mean(f::Union{Function, Type}, itr) in Statistics at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Statistics/src/Statistics.jl:58
[3] mean(r::AbstractRange{#s549} where #s549<:Real) in Statistics at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Statistics/src/Statistics.jl:134
[4] mean(A::AbstractArray; dims) in Statistics at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Statistics/src/Statistics.jl:128
[5] mean(itr) in Statistics at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Statistics/src/Statistics.jl:42

#3

补充 “渔”

找函数去 v0.7 里 help 一下就好

help?> mean
search: SegmentationFault macroexpand @macroexpand @macroexpand1 module_parent Meta numerator enumerate timedwait

WARNING: Base.mean is deprecated: it has been moved to the standard library package `Statistics`.
Add `using Statistics` to your imports.

#4

好的,收的,得到解决了。