Selecting values from bounded normal distribution in NetLogo

烈酒焚心 提交于 2019-12-10 22:56:53

问题


I'm trying to have NetLogo draw values from a bounded random normal distribution following the recommendation in a previous question in stackoverflow

NetLogo : How to make sure a variable stays in a defined range?

Specifically I'm asking the model to create a circular home range that varies in size according to empirical data

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

However I keep getting the error that random-normal-in-bounds expected 4 inputs. I'm sure it's something silly I'm doing but it looks like 4 inputs (54.4, 35.8, 19, 151) to me. Any suggestions on what I'm doing wrong? Thanks in advance!


回答1:


I think your error is caused by [] you don't need these brackets.

Update:

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



来源:https://stackoverflow.com/questions/21148717/selecting-values-from-bounded-normal-distribution-in-netlogo

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