How to get a random number from rand that is not an array?

Hello,

Is it possible to generate a random number that is not a Vector{Float64} but just Float64? I want to change the value but the types don’t match. Is there a way to do this?

a = 4
d = 7

qwe = zeros(a+d)
asd = zeros(length(qwe))

asd[1:a] = rand(Uniform(0,10), a)
asd[a+1:end] = rand(Uniform(0,10), d)
asd

asd[end-1] = rand(Uniform(0,10), 1)

MethodError: Cannot `convert` an object of type Array{Float64,1} to an object of type Float64

rand()

2 Likes

:sweat_smile: Oh my…

2 Likes

Or in this case rand(Uniform(1, 10)).

1 Like