【发布时间】:2017-04-05 11:39:35
【问题描述】:
我正在尝试计算单个补丁上的海龟拥有因子的方差。换句话说,在单个补丁中,我想知道该补丁上所有海龟的因子的均值和方差。
我知道'mean [FACTOR] of turtles-here'会给我平均值,但由于某种原因,方差不能正常工作。 问题 1:要求补丁输出海龟拥有因子的方差的正确语法是什么?
我设计了一个超级简单的示例模型。只需将其粘贴到您的代码中,然后在界面上创建“设置”和“开始”按钮。它应该有粉红色的海龟在黑色的斑块上寻找和停下来。
turtles-own
[FACTOR]
patches-own
[DEPTH]
to setup
clear-all
reset-ticks
make_patches
make_turtles
end
to go
move
if count (turtles with [DEPTH > 0]) = 0 [stop]
end
to make_patches
ask patches [set depth 20 set pcolor green - 2]
ask n-of 5 patches [set depth -50 set pcolor black]
end
to make_turtles
create-turtles 10
ask turtles
[
set color pink
set size 2
set xcor random max-pxcor
set ycor random max-pycor
set FACTOR random 100
]
end
to move
ask turtles[
let D min [DEPTH] of patches in-radius 3
let Dn min-one-of patches in-radius 3 [DEPTH]
let LDe [DEPTH] of patch-here
ifelse DEPTH < 0
[
move-to patch-here
stop
]
[ifelse LDE > D AND D < 0
[
move-to DN
stop
]
[
right random-float 150
forward random 3
]
]
]
end
最后,我想做一个行为空间实验,在每次运行结束时,每个 DEPTH
ask patches with [DEPTH< 0] [set FACTOR_LIST (list ("[")(COORDINATES) (",") (VARIANCE_FACTOR) ("]") )]
其中 FACTOR_LIST 是导出的列表,COORDINATES 是由补丁的 x 和 y 坐标组成的列表,而 VARIANCE_FACTOR 是因子的方差(我在这里询问如何做)。 问题 2:有没有更有效的方法来获取此列表?
非常感谢!
【问题讨论】:
标签: netlogo