4

I am new both to NetLogo (NL) and Stackoverflow. I am working on NL model of opinion formation and I am stuck with following problem (googling or anything else didn't work for me).

First, turtle-own property turtles-own [opinion] is defined. Next, there is a random normal distribution of opinion variable (ranges from -1 to 1). I want to be able to account for different shapes of opinion distribution in range from -1 to 1. This is done by using random-normal command with two inputs: mean (set to 0) and std. dev. (set by slider); i.e. the shape is given by the std. dev. value.

Here is a code of setup function:

to setup
clear-all
random-seed seed
crt number
ask turtles [set opinion random-normal 0 std.dev.]
... (defining other turtles properties)
end

Nevertheless, setting std.dev. slider to 1 does not produce expected outcome (bell-shaped distribution), but rather uniform distribution. I am not sure whether this is a conceptual or technical problem.

Any help is much appreciated.

Crono
  • 10,211
  • 6
  • 43
  • 75

1 Answers1

3

Normal distributions don't have a restricted range, thus I'm not sure you want to use random-normal. There are a variety of methods of getting bounded normal-like distributions. See this answer for details: NetLogo : How to make sure a variable stays in a defined range?

As to why it's not looking bell-shaped, how are you visualizing the resulting distribution? histogram can be a little finicky sometimes as you have to explicitly set the x-min, x-max, and bin size. Here's what I get with 10,000 turtles, a standard deviation of 1, x-min = -5, x-max = 5, and interval = 0.1:

Distribution of opinions

To set the bin size, hit the edit button (looks like a pencil) on the plot pen that's drawing the histogram. Set interval on the resulting dialogue to your desired bin size. Let me know if you'd like more detailed instructions for using histogram.

Community
  • 1
  • 1
Bryan Head
  • 12,360
  • 5
  • 32
  • 50
  • Thank you. I had restricted the x-axis to [-1, 1] interval, so the plot displayed only a part of the normal distribution. Now I am using `ask turtles [set opinion median (list -1 (random-normal 0 std.dev.) 1)]` as suggested in the other thread. This works fine, nevertheless the std. dev. value for bell-shape like distribution is around 0.3. – petr.ocelik Feb 27 '14 at 17:30