JuliaStats / StatsBase.jl

Basic statistics for Julia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AbstractVector{T} not accepting Vector{Any} as argument

jtancp opened this issue · comments

I am trying to work with the autocor function and am taking a column of a data frame and changing it to a vector. typeof(col) is telling me that it is Vector{Any}. When I pass the argument ACF = StatsBase.autocor(col, (1:18); demean = true)I get the error

ERROR: MethodError: no method matching autocor(::Vector{Any}, ::UnitRange{Int64})
Closest candidates are:
  autocor(::AbstractVector{T} where T<:Real, ::AbstractVector{T} where T<:Integer; demean) at ~/.julia/packages/StatsBase/XgjIN/src/signalcorr.jl:194

I am able to run the function after passing the argument col = Float64.(col) Does julia intentionally make you specify type or is this an issue.

We generally assume that the element types are more specific than Any. It's quite useful since we can then e.g. avoid considering complex numbers in the function. For performance, it's also beneficial if your element type is Float64 instead of Any.