# UndefVarError: \`Random\` not defined

**URL:** <https://discourse.julialang.org/t/undefvarerror-random-not-defined/101142>\
**Category:** General Usage\
**Tags:** question, random\
**Created:** [July 3, 2023, 8:36pm UTC](https://discourse.julialang.org/t/undefvarerror-random-not-defined/101142 "2023-07-03T20:36:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Post date:** [July 3, 2023, 8:36pm UTC](https://discourse.julialang.org/t/undefvarerror-random-not-defined/101142/1 "2023-07-03T20:36:29Z")

</div>

I tried to use the function with Random as below:

```julia
init_params = Float64.(ComponentArray(Lux.setup(Random.default_rng(), chain)[1]))

```

and I got the message: `UndefVarError: `Random` not defined`. Please help me to fix it.  
Thank you all.

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [July 3, 2023, 8:38pm UTC](https://discourse.julialang.org/t/undefvarerror-random-not-defined/101142/2 "2023-07-03T20:38:44Z")

</div>

`Random` isn’t in `Base`, you have to import it, with `import Random` or `using Random`. It’s in the standard library, though, so you don’t need to install anything new.
