我正在尝试让NetLogo根据stackoverflow中上一个问题中的建议从有界随机正态分布中绘制值
NetLogo : How to make sure a variable stays in a defined range?
具体而言,我要求模型根据经验数据创建一个大小不同的圆形家庭范围
set homerange patches in-radius ((sqrt (( random-normal-in-bounds [ 54.4 35.8 19 151 ] * 1000000)/ pi))/ 100)
to-report random-normal-in-bounds [mid dev mmin mmax]
let result random-normal mid dev
if result < mmin or result > mmax
[ report random-normal-in-bounds mid dev mmin mmax ]
report result
end
但是我不断得到随机正常入境预期4个输入的错误。我确定这是我在做的傻事,但它看起来像4输入(54.4,35.8,19,151)给我。关于我做错的任何建议?提前谢谢!
答案 0 :(得分:1)
我认为您的错误是由[]引起的,您不需要这些括号。
更新
to test
clear-all
let homerange nobody
let radius sqrt (( random-normal-in-bounds 54.4 35.8 19 151 * 1000000)/ pi) / 100
crt 1 [
set homerange patches in-radius radius
]
ask homerange [set pcolor violet]
end
to-report random-normal-in-bounds [mid dev mmin mmax]
let result random-normal mid dev
if result < mmin or result > mmax
[ report random-normal-in-bounds mid dev mmin mmax ]
report result
end