0
我正試圖計算單個補丁上龜的擁有因子的方差。換句話說,在一個補丁中,我想知道該補丁中所有龜的因素的均值和方差。在netlogo中計算單個補丁上的龜擁有因子的方差
我知道'烏龜的意思[因素] - 在這裏'會給我的意思,但由於某種原因,差異不是很好。 問題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 < 0計算每個補丁並輸出平均值,標準偏差,和因子的方差爲龜那確切的補丁。我的計劃是創建排序列表
ask patches with [DEPTH< 0] [set FACTOR_LIST (list ("[")(COORDINATES) (",") (VARIANCE_FACTOR) ("]"))]
其中FACTOR_LIST被導出列表,座標由x和補丁的y座標列表,並VARIANCE_FACTOR是因子的方差(我在這裏要問怎麼辦)。 問題2:是否有更有效的方法來獲取此列表?
非常感謝!