# 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:** 20

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [March 17, 2019, 1:51am UTC](https://discourse.julialang.org/t/how-to-create-a-random-uniform-distribution-between-but-excluding-0-and-10/21908/20 "2019-03-17T01:51:55Z")

</div>

Just to try to prevent this thread being overwhelming for a newcomer, let me just highlight the straightforward answer:

```julia
10*(1-rand())

```

Analysis:

- `rand()` is uniform from `[0, 1)`
- `1-rand()` is uniform from `(0, 1]`
- `10*(1-rand())` is uniform from `(0, 10]`

This is a totally fine, simple answer. Is it perfectly uniformly distributed? Meh, maybe, maybe not but the chance that it matters for this use case is negligible.

---

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