设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10568|回复: 2

[求助] netlogo编程关于随机数的求助

  [复制链接]
发表于 2015-1-7 11:27:22 | 显示全部楼层 |阅读模式
在netlogo模型库中有一个virus on a network,里面有一个代码to spread-virus1 Z% T4 Z' t" K
  ask turtles with [infected?]
7 I4 ?" C$ R! Z1 ?; a    [ ask link-neighbors with [not resistant?]
' n( Y6 T. t" M  u. t     [ if random-float 100 < virus-spread-chance4 ?) P, S7 ]; k) R- k& D' i5 s
            [ become-infected ] ] ]
# L. p5 F5 }" U" O  |9 m2 z
end
& S# f* R7 \" g这里为什么virus-spread-chance大于random-float 100,就可以判断出become-infected呢?
$ Q8 a4 D; J) f$ vto do-virus-checks9 K+ h  O4 H6 S% Z' F4 i
  ask turtles with [infected? and virus-check-timer = 0]3 N% j- t  _; n* b# w. S
  [5 d4 U: M% Z* G7 Y. l2 h$ `( A4 ]  Y: `
    if random 100 < recovery-chance0 y3 v' F  w( w4 _
    [: ~1 i3 k: R* E  S, d
      ifelse random 100 < gain-resistance-chance
0 B  Q9 }7 M4 v+ n/ H5 R        [ become-resistant ]) r: s; `6 p0 b. O+ `4 r
        [ become-susceptible ]7 t5 n6 |; Z5 K; y
    ]! R5 q4 P/ j" q3 J8 [! y
  ]9 e& T- D& J; G9 S+ E3 k
end
$ R( N. ^1 S( m. @, Q8 w下面同样这个问题不明白
* M9 s  @1 c8 Q! n. T* H* V小妹求大神帮忙!!
7 p; Z' E$ d9 E8 t- C3 D& ]
 楼主| 发表于 2015-1-7 11:28:08 | 显示全部楼层
自己顶一下,文科生,真心难写编程
发表于 2016-3-27 16:49:39 | 显示全部楼层
这是用于概率计算的一种表示方法,例如,若virus-spread-chance=5,那么在100以内随机生成一个数字,小于5的可能情况,只有4、3、2、1、0,塔门出现的概率只有5%,也就是海龟被感染的可能性为5%。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-6-26 20:38 , Processed in 0.012311 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表