0

I'm creating a virtual society where turtles have a 3 dimensional vector of opinions.What I'd like is that each turtle in the network has a vector of opinions that is related to turtles in the network following a normal distribution.

A possibility I reckon would be to create turtles with random opinions and then at the end of the setup process bring these opinions close together . So for instance, turtle 0 has opinions [0.2 0.8 0.6], turtle 1 has [0.7 0.5 0.5] and turtle 2 has [0.9 0.4 0.1]. The mean being [0.6 0.6 0.1], then each turtle's vector of opinions would be reestablished following a normal distribution [0.6±0.1 0.6±0.1 0.6±0.1]

Below what I am trying, which doesn't work because my (map mean ([opinions] of my-nearby-turtles)bit gives the mean of all dimensions of opinions for each turtle instead of the mean of each dimension of opinions for all turtles...

ask turtles [
        set opinions n-values 3 [random-float 1]
        (foreach opinions (map mean ([opinions] of turtles)) [ [a b] -> set a random-normal b 0.1])
      ]
end
lomper
  • 379
  • 1
  • 12
  • 1
    Can you please provide some example data? Pretend that the turtle has 3 neighbours and create some vectors with fake values, what do you want the turtle to actually generate from the neighbours' vectors? – JenB Jul 08 '19 at 16:35
  • Thanks for your quick response @JenB. I have modified my question to try and be clearer, let me know if you need more details to help me figure this out! – lomper Jul 09 '19 at 09:32
  • @JenB I used some of what you taught me elsewhere to cobble up an answer, I think it works but I'll keep testing... Thanks! – lomper Jul 09 '19 at 16:20

1 Answers1

0

I think I may have tackled it, I await comments from more senior NetLoggers...

ask turtles [
   set opinions n-values 3 [random-float 1]
  (foreach opinions [x ->
    let avg-network map mean ([opinions] of turtles)
    let pp position x opinions
    set opinions replace-item pp opinions random-normal (item pp avg-network) 0.1])
  ]
end
lomper
  • 379
  • 1
  • 12