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

**URL:** <https://discourse.julialang.org/t/how-to-get-a-random-number-from-rand-that-is-not-an-array/42304>\
**Category:** New to Julia\
**Created:** [June 30, 2020, 2:25pm UTC](https://discourse.julialang.org/t/how-to-get-a-random-number-from-rand-that-is-not-an-array/42304 "2020-06-30T14:25:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [June 30, 2020, 2:25pm UTC](https://discourse.julialang.org/t/how-to-get-a-random-number-from-rand-that-is-not-an-array/42304/1 "2020-06-30T14:25:59Z")

</div>

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?

```julia
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

```

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [June 30, 2020, 2:36pm UTC](https://discourse.julialang.org/t/how-to-get-a-random-number-from-rand-that-is-not-an-array/42304/2 "2020-06-30T14:36:17Z")

</div>

`rand()`

---

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [June 30, 2020, 2:37pm UTC](https://discourse.julialang.org/t/how-to-get-a-random-number-from-rand-that-is-not-an-array/42304/3 "2020-06-30T14:37:38Z")

</div>

😅 Oh my…

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [June 30, 2020, 2:37pm UTC](https://discourse.julialang.org/t/how-to-get-a-random-number-from-rand-that-is-not-an-array/42304/4 "2020-06-30T14:37:42Z")

</div>

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