Ali Bahrami
Ali Bahrami

Reputation: 11

BoundsError: attempt to access 1-element Array{Any,1} at index [2]

for i in 1:1000
    x = rand(Uniform(0,4),100)
    mean_array[i] = sum(x)/ 100
end

I wanna generate 1000 dists and calculate the mean of each one and put the means in an array to get another mean from this 1000 means.

Upvotes: 0

Views: 821

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42194

Your code can be written as:

mean_array=[mean(rand(Uniform(0,4),100)) for i in 1:100]

Upvotes: 2

Related Questions