设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9651|回复: 2

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

  [复制链接]
发表于 2015-1-7 11:27:22 | 显示全部楼层 |阅读模式
在netlogo模型库中有一个virus on a network,里面有一个代码to spread-virus
, W7 y9 l, n/ ?4 C1 N3 z  ask turtles with [infected?]
/ b3 s3 Y9 V7 |. j    [ ask link-neighbors with [not resistant?]
: x! F4 v- D5 p/ M  N$ A* L/ C. x8 G     [ if random-float 100 < virus-spread-chance
, o+ Y- _* `  }7 U3 c/ g% G            [ become-infected ] ] ]

) N- q" Q; W/ |/ _/ J! Mend$ f' {8 e& Q4 l4 @. f- n. a. ]# S
这里为什么virus-spread-chance大于random-float 100,就可以判断出become-infected呢?
. B% q) i! J0 H% a- i7 mto do-virus-checks
# J/ D  v% ]$ x- A, {0 y0 A  ask turtles with [infected? and virus-check-timer = 0]
/ Z/ S8 @3 I- C( [1 V  y( i& A  [9 m8 v" W* i. u$ l  b) ]
    if random 100 < recovery-chance
+ R# f3 D7 }+ X# n    [! ]" y+ f$ w% W6 J# d6 E' N8 }" y
      ifelse random 100 < gain-resistance-chance
( }& z( a/ n* L* h        [ become-resistant ]9 A) G  s6 q% S4 y. j# b& r
        [ become-susceptible ]: l- h& H* B9 n3 j
    ]; P# f' q/ A. x6 p6 V
  ]1 D" ~1 n; B6 i& s! @; P
end
+ e4 M2 J- M* p* `. \下面同样这个问题不明白) B. U' `. a* t3 r2 ]
小妹求大神帮忙!!
* b6 s4 U% l! W. _4 h' [
 楼主| 发表于 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, 2025-12-14 13:59 , Processed in 0.016470 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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