# How to create a random Uniform Distribution between (but excluding) 0 and 10?

**URL:** <https://discourse.julialang.org/t/how-to-create-a-random-uniform-distribution-between-but-excluding-0-and-10/21908>\
**Category:** New to Julia\
**Created:** [March 15, 2019, 10:54am UTC](https://discourse.julialang.org/t/how-to-create-a-random-uniform-distribution-between-but-excluding-0-and-10/21908 "2019-03-15T10:54:42Z")\
**Posts on this page:** 1\
**Showing post:** 21

<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 17, 2019, 2:28am UTC](https://discourse.julialang.org/t/how-to-create-a-random-uniform-distribution-between-but-excluding-0-and-10/21908/21 "2019-03-17T02:28:09Z")

</div>

If you want to exclude both 0 and 10, you can use `prevfloat(10.0)*(1-rand())` instead.  
Same argument you gave applies, the answer being uniform from `(0, prevfloat(10.0)]`, i.e. `(0,10)`.

If you don’t, the probability of getting a 10 on any given draw is `1/2^52 = 2.220446049250313e-16`.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-create-a-random-uniform-distribution-between-but-excluding-0-and-10/21908)._
