# Uniformal distribution

**URL:** https://discourse.julialang.org/t/uniformal-distribution/78161
**Category:** New to Julia
**Tags:** question
**Created:** [March 20, 2022, 10:38am UTC](https://discourse.julialang.org/t/uniformal-distribution/78161 "2022-03-20T10:38:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mahmoud](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Mahmoud](https://discourse.julialang.org/u/Mahmoud)
#### Post date: [March 20, 2022, 10:38am UTC](https://discourse.julialang.org/t/uniformal-distribution/78161/1 "2022-03-20T10:38:56Z")

</div>

I have a length L=44 and I have 100 particles (each particle is an object who has its own x and y variables to locate its location in the future).  
I want to uniformly distribute the 100 particles in a square of length L  
Like this photo \>  
 ![Color-online-An-example-of-well-sampled-2D-uniformly-distributed-data-points-blue](https://global.discourse-cdn.com/julialang/original/3X/d/1/d1ad8b1f5d6ce21745e3da92fcf8bacd5a42cb01.png)  
.

---

<div class="post-metadata">

### Author: ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)
#### Post date: [March 20, 2022, 12:45pm UTC](https://discourse.julialang.org/t/uniformal-distribution/78161/2 "2022-03-20T12:45:25Z")

</div>

So ten particles per line. Sounds a bit like homework. 😉

```julia
L = 44
x = L/10 * (range(1,10).-0.5)
collect(Iterators.product(x,x))

```

> **Output**
>
> ```julia
> 10×10 Matrix{Tuple{Float64, Float64}}:
> (2.2, 2.2) (2.2, 6.6) (2.2, 11.0) (2.2, 15.4) … (2.2, 28.6) (2.2, 33.0) (2.2, 37.4) (2.2, 41.8)
> (6.6, 2.2) (6.6, 6.6) (6.6, 11.0) (6.6, 15.4) (6.6, 28.6) (6.6, 33.0) (6.6, 37.4) (6.6, 41.8)
> (11.0, 2.2) (11.0, 6.6) (11.0, 11.0) (11.0, 15.4) (11.0, 28.6) (11.0, 33.0) (11.0, 37.4) (11.0, 41.8)
> (15.4, 2.2) (15.4, 6.6) (15.4, 11.0) (15.4, 15.4) (15.4, 28.6) (15.4, 33.0) (15.4, 37.4) (15.4, 41.8)
> (19.8, 2.2) (19.8, 6.6) (19.8, 11.0) (19.8, 15.4) (19.8, 28.6) (19.8, 33.0) (19.8, 37.4) (19.8, 41.8)
> (24.2, 2.2) (24.2, 6.6) (24.2, 11.0) (24.2, 15.4) … (24.2, 28.6) (24.2, 33.0) (24.2, 37.4) (24.2, 41.8)
> (28.6, 2.2) (28.6, 6.6) (28.6, 11.0) (28.6, 15.4) (28.6, 28.6) (28.6, 33.0) (28.6, 37.4) (28.6, 41.8)
> (33.0, 2.2) (33.0, 6.6) (33.0, 11.0) (33.0, 15.4) (33.0, 28.6) (33.0, 33.0) (33.0, 37.4) (33.0, 41.8)
> (37.4, 2.2) (37.4, 6.6) (37.4, 11.0) (37.4, 15.4) (37.4, 28.6) (37.4, 33.0) (37.4, 37.4) (37.4, 41.8)
> (41.8, 2.2) (41.8, 6.6) (41.8, 11.0) (41.8, 15.4) (41.8, 28.6) (41.8, 33.0) (41.8, 37.4) (41.8, 41.8)
> 
> ```

---

<div class="post-metadata">

### Author: ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)
#### Post date: [March 20, 2022, 2:49pm UTC](https://discourse.julialang.org/t/uniformal-distribution/78161/3 "2022-03-20T14:49:07Z")

</div>

Or simply, a `tuple`:

```julia
julia> L = 44;

julia> tuple.(0.5L/10:L/10:L, (0.5L/10:L/10:L)')
10×10 Matrix{Tuple{Float64, Float64}}:
 (2.2, 2.2) (2.2, 6.6) (2.2, 11.0) … (2.2, 37.4) (2.2, 41.8)
 (6.6, 2.2) (6.6, 6.6) (6.6, 11.0) (6.6, 37.4) (6.6, 41.8)
 (11.0, 2.2) (11.0, 6.6) (11.0, 11.0) (11.0, 37.4) (11.0, 41.8)
 (15.4, 2.2) (15.4, 6.6) (15.4, 11.0) (15.4, 37.4) (15.4, 41.8)
 (19.8, 2.2) (19.8, 6.6) (19.8, 11.0) (19.8, 37.4) (19.8, 41.8)
 (24.2, 2.2) (24.2, 6.6) (24.2, 11.0) … (24.2, 37.4) (24.2, 41.8)
 (28.6, 2.2) (28.6, 6.6) (28.6, 11.0) (28.6, 37.4) (28.6, 41.8)
 (33.0, 2.2) (33.0, 6.6) (33.0, 11.0) (33.0, 37.4) (33.0, 41.8)
 (37.4, 2.2) (37.4, 6.6) (37.4, 11.0) (37.4, 37.4) (37.4, 41.8)
 (41.8, 2.2) (41.8, 6.6) (41.8, 11.0) (41.8, 37.4) (41.8, 41.8)

```
