在netlogo中绘制一个随机Beta分布 [英] Draw a random-beta distribution in netlogo

查看:125
本文介绍了在netlogo中绘制一个随机Beta分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试生成一个品种拥有的变量,该变量从Netlogo中的随机beta分布得出其值.

I'm attempting to generate a breed-owned variable which draws it's values from a random beta distribution in Netlogo.

我在网上找到了"bc"代码示例,但正在努力使其适应我的需求.现在,为方便起见,我已经使用

I've found the "bc" code example online but am struggling to adapt it to what I need. Right now, for convenience, I've generate my distribution from a random-normal distribution using

create-breed 500
 [
  set target_factor random-normal 0.9 0.05
  if target_factor > 1 [set target_factor 0.9999999999]
  if target_Factor < 0.5 [set target_factor 0.5000000001]
 ]

所以基本上我想找一个可以用随机beta分布代替随机正态0.9 0.05"部分的报告器

So basically I'd like to get a reporter that can replace the "random-normal 0.9 0.05" part with a random beta distribution

我到目前为止:

to-report random_beta
  set asocial_alpha 2
  set asocial_beta 2
  set asocial_min_eps 0
  set asocial_max_eps 0.25
  let x random-gamma asocial_alpha 1
  let asocial_eps (x / (x + random-gamma asocial_beta 1))
  set asocial_eps asocial_min_eps + (asocial_eps * (asocial_max_eps -   asocial_min_eps)) 
 foreach ( n-values 99 [ (? + 1) / 100 * (asocial_max_eps -     asocial_min_eps) + asocial_min_eps] ) 
  [report ? ( ((? - asocial_min_eps) ^ (asocial_alpha - 1) * (asocial_max_eps - ?) ^ (asocial_beta - 1)) / ( asocial_max_eps - asocial_min_eps ) ^ (asocial_alpha + asocial_beta - 1) )]
end

这里的所有设置"变量都是全局因素

all of the 'set' variables here are global factors

老实说,我在数学上超出了我的理解范围.如果有人可以帮助我修复此报告者(或者某个程序也可以).所以我最终的品种创建代码是:

I'm honestly out of my depth with this one mathematically. If anyone can help me fix this reporter (or if a procedure would work that's fine too). so my final code for breed creation is:

create-breed 500
 [
  set target_factor random-beta
  if target_factor > 1 [set target_factor 0.9999999999]
  if target_Factor < 0.5 [set target_factor 0.5000000001]
 ]

我将永远感激!!

推荐答案

rngs扩展名提供了随机的beta分布(还有许多其他分布).您可以在这里找到它: https://github.com/NetLogo/NetLogo/wiki/Extensions.

The rngs extension provides a random beta distribution (among many others). You can find it here: https://github.com/NetLogo/NetLogo/wiki/Extensions.

查尔斯

这篇关于在netlogo中绘制一个随机Beta分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆