设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10507|回复: 2

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

  [复制链接]
发表于 2015-1-7 11:27:22 | 显示全部楼层 |阅读模式
在netlogo模型库中有一个virus on a network,里面有一个代码to spread-virus
. N; e  H. x+ E  ask turtles with [infected?]
: ^! J* Z3 r6 F: {    [ ask link-neighbors with [not resistant?]; m# @, J4 q1 n) ]% H; r9 p; _& G! K
     [ if random-float 100 < virus-spread-chance
  l: K, Q  F3 O- ]            [ become-infected ] ] ]
' {8 c4 @, P9 o8 |' `# u
end0 @1 T4 S& ~1 J) _: o
这里为什么virus-spread-chance大于random-float 100,就可以判断出become-infected呢?
& q! g5 n2 L( c! e6 q7 E6 Yto do-virus-checks9 M9 H5 u/ J9 ~) k& E, k
  ask turtles with [infected? and virus-check-timer = 0]. e8 y" X$ x$ ~! [+ i: p( S. ~
  [
- l3 b1 r7 n4 e8 C  U; U    if random 100 < recovery-chance( b+ G& S* D5 J! ~+ q7 N& C; O
    [
& W: d  u5 p6 c( d5 y  t8 f7 G+ @' D      ifelse random 100 < gain-resistance-chance" x* E; h9 a7 ?$ ]9 ^
        [ become-resistant ]
! I5 ^8 u( E! E: }        [ become-susceptible ]
; W, g+ k3 ^8 L/ G; j    ]* O6 P$ e% Q0 t8 |
  ]3 {1 _3 Y! c; U2 O2 P4 N0 Q
end
4 y4 L' I! x, }' h- S下面同样这个问题不明白
# S7 m4 q3 h; Y' ]小妹求大神帮忙!!
9 b' }# w% k2 R" P; M+ ?
 楼主| 发表于 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-15 16:47 , Processed in 0.013337 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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