I am creating an array of size 100 using three different methods. But I don’t understand why the
@time results are different between them.
Here is the code
Main> @time dpc = [Int(round(rand(PP_DD))) for i=1:100]; 0.033401 seconds (9.36 k allocations: 511.468 KiB) Main> @time dpc = Int.(round.(rand(PP_DD, 100))); 0.020636 seconds (4.13 k allocations: 235.887 KiB) Main> @time begin dpc = zeros(Int64, 100) for i = 1:100 dpc[i]=Int(round(rand(PP_DD))) end end 0.000056 seconds (201 allocations: 4.000 KiB)
PP_DD = Normal(4.5, 1)