How store/count individual cluster sizes and plot them in NetLogo

笑着哭i 提交于 2019-12-05 16:58:32

Basically, for each cluster value in your model, you want to count all patches with the same identifier. This can be acchieved by using map. It uses a list of unique patch cluster values (remove-duplicates [cluster] of patches) and then for each entry in that list it counts all patches with this cluster value. The results are stored in a list and they represent the sizes of all your clusters. This list can be plotted as a frequency histogram by using the histogram primitive. Be sure to set the x-Axis of your plot to a plausible maximum value and set the plot pen to bar mode.

NetLogo 6 syntax:

to calc-frequency
  let freq map [[i] -> count patches with [cluster = i]] remove-duplicates [cluster] of patches

  set-current-plot "hist"
  histogram freq
end

NetLogo 5 syntax:

to calc-frequency
  let freq map [count patches with [cluster = ?]] remove-duplicates [cluster] of patches

  set-current-plot "hist"
  histogram freq
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!