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

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

I would like the distibution to look more like this:

image

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

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:

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

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

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

foo = rand(Poisson(r),N)

Note that with all of these you should first be doing

using Distributions

Got it. Thank you very much.

1 Like