I’m just getting started using Julia. My version is 1.0.3 on Ubuntu 16.04. I was trying to create an array of Normal Distribution objects in the REPL using a for loop as follows:
using Distributions
means = 10*rand(10)
d = []
for j = 1:size(means,1)
append!(d, Normal(means[j]))
end
However, the code threw the following error:
ERROR: MethodError: no method matching iterate(::Normal{Float64})
Closest candidates are:
iterate(::Core.SimpleVector) at essentials.jl:589
iterate(::Core.SimpleVector, ::Any) at essentials.jl:589
iterate(::ExponentialBackOff) at error.jl:171
...
Stacktrace:
[1] zip_iterate(::UnitRange{Int64}, ::Normal{Float64}, ::Tuple{}, ::Tuple{}) at ./iterators.jl:304
[2] iterate at ./iterators.jl:320 [inlined]
[3] _append!(::Array{Any,1}, ::Base.HasLength, ::Normal{Float64}) at ./array.jl:909
[4] append!(::Array{Any,1}, ::Normal{Float64}) at ./array.jl:902
[5] top-level scope at ./REPL[58]:2 [inlined]
[6] top-level scope at ./none:0
Not quite sure what the problem is. Can Distribution objects not be stored in arrays?