# True random numbers

**URL:** <https://discourse.julialang.org/t/true-random-numbers/111593>\
**Category:** Community\
**Tags:** random\
**Created:** [March 13, 2024, 9:46pm UTC](https://discourse.julialang.org/t/true-random-numbers/111593 "2024-03-13T21:46:27Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [March 14, 2024, 4:41am UTC](https://discourse.julialang.org/t/true-random-numbers/111593/4 "2024-03-14T04:41:09Z")

</div>

> [@Palli](#):
>
> Julia’s rand is NOT ok for cryptography, but Julia’s stdlib allows for that, if I recall, _it’s just non-default_, and it accesses (on Linux), if I recall:

```julia
julia> using Random

help?> Random.RandomDevice
  RandomDevice()

  Create a RandomDevice RNG object. Two such objects will always generate different streams of random numbers. The entropy is obtained from the operating system.

julia> rand(RandomDevice())
0.3682754503315735

```

“Two such objects will always generate different streams” is a really strong guarantee.

As for PRNGs, they can be difficult to tell apart from “truly random”, e.g. see [GitHub - JuliaRandom/RNGTest.jl: Code for testing of Julia's random numbers](https://github.com/JuliaRandom/RNGTest.jl)  
If you’re doing cryptography, you’re going to have higher standards.  
If you’re doing Monte Carlo, you’ll want PRNGs; so long as you don’t have overlapping streams between threads, being pseudo-random won’t impact accuracy, while their better speed will improve accuracy/second (i.e., can sample more in the same amount of time, or sample for less time).

---

_[View the full topic](https://discourse.julialang.org/t/true-random-numbers/111593)._
