# Is it possible to create a non-normal distribution of agents on a grid using Agents.jl?

**URL:** https://discourse.julialang.org/t/is-it-possible-to-create-a-non-normal-distribution-of-agents-on-a-grid-using-agents-jl/119351
**Category:** Modelling & Simulations
**Tags:** plotting
**Created:** [September 12, 2024, 9:51pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-non-normal-distribution-of-agents-on-a-grid-using-agents-jl/119351 "2024-09-12T21:51:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tfranks](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tfranks](https://discourse.julialang.org/u/tfranks)
#### Post date: [September 12, 2024, 9:51pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-non-normal-distribution-of-agents-on-a-grid-using-agents-jl/119351/1 "2024-09-12T21:51:19Z")

</div>

Hello,

Using Julia Agents.jl, I’ve built an agent-based model where the bank agents are plotted on a x-y axis and added to the grid by “add\_agents!.” This function adds the agents in a normal distribution as shown below.

![image](https://global.discourse-cdn.com/julialang/original/3X/d/3/d33b08a1eaf180d9e91ba180d3a1a974644175ad.png)

I would like the distibution to look more like this:

![image](https://global.discourse-cdn.com/julialang/original/3X/3/7/376c386b38966160ae650d8ff8e8229481090840.png)

The current code that produces a normal distribution is

> Blockquote

#add Bank agents  
for \_ in 1:n\_banks  
add\_agent!(Bank, model;  
uninsured = rand(),  
investments = 2 \* rand(),  
totDep = 100,  
AFS\_securities = rand(1:10),  
social\_network = rand(1:3),  
vul = false,  
health = true,  
acolor = :black,  
interest\_rate = rand(1:10),  
)  
end

> Blockquote

Thank you for your advice. Best,  
Terrie

---

<div class="post-metadata">

### Author: ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)
#### Post date: [September 12, 2024, 10:21pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-non-normal-distribution-of-agents-on-a-grid-using-agents-jl/119351/2 "2024-09-12T22:21:01Z")

</div>

When you say a “normal” distribution, I believe what you mean is a “uniform” distribution. In fact, the distribution you want is closer to a “normal” (ie. gaussian) one.

you could do something like:

```julia
xes = rand(Normal(40,20),N)
yes = rand(Normal(75,10),N)

for (x,y) in zip(xes,yes)
   add_agent!(Bank,model; uninsured = x, investments = y...)
end

```

---

<div class="post-metadata">

### Author: ![tfranks](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tfranks](https://discourse.julialang.org/u/tfranks)
#### Post date: [September 12, 2024, 10:24pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-non-normal-distribution-of-agents-on-a-grid-using-agents-jl/119351/3 "2024-09-12T22:24:00Z")

</div>

Thank you for your quick response. What would Poisson look like? Could replace “Poisson” with “Normal”? Thanks.

---

<div class="post-metadata">

### Author: ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)
#### Post date: [September 12, 2024, 10:25pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-non-normal-distribution-of-agents-on-a-grid-using-agents-jl/119351/4 "2024-09-12T22:25:35Z")

</div>

if you wanted to generate N Poisson random values all with the same rate r, you could do:

```julia
foo = rand(Poisson(r),N)

```

Note that with all of these you should first be doing

`using Distributions`

---

<div class="post-metadata">

### Author: ![tfranks](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tfranks](https://discourse.julialang.org/u/tfranks)
#### Post date: [September 12, 2024, 10:26pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-non-normal-distribution-of-agents-on-a-grid-using-agents-jl/119351/5 "2024-09-12T22:26:51Z")

</div>

Got it. Thank you very much.
