设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9164|回复: 2

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

  [复制链接]
发表于 2015-1-7 11:27:22 | 显示全部楼层 |阅读模式
在netlogo模型库中有一个virus on a network,里面有一个代码to spread-virus
+ J5 S  @* @/ y' v; Z( I  ask turtles with [infected?]
0 Y) G2 P0 k: p6 X# X3 Q2 F4 i    [ ask link-neighbors with [not resistant?]) c6 z- g# m+ a& h; V9 S6 x  @
     [ if random-float 100 < virus-spread-chance. }1 a  f& @7 s0 B* a, Y
            [ become-infected ] ] ]

1 s$ N: C# F9 \! f6 s; [: G* s4 |end6 g% G6 `2 ~7 W5 E; t
这里为什么virus-spread-chance大于random-float 100,就可以判断出become-infected呢?1 x: ^7 r8 k0 g7 M4 o; }
to do-virus-checks
1 x) J) V* W% Q  ask turtles with [infected? and virus-check-timer = 0]
5 n0 P* c* m0 [) J$ W* l2 b  [6 |! o% w+ b9 B8 @; j
    if random 100 < recovery-chance0 T% Y8 o) p4 i; m' C
    [# u- C" x0 A. p/ N3 B% d, {
      ifelse random 100 < gain-resistance-chance9 z( R: d+ j+ s
        [ become-resistant ]
/ n3 w! c* N1 v/ h) l% G7 @        [ become-susceptible ]
0 V4 x* ^  A) \    ]7 z1 g; Q4 C5 ~# ~, ~
  ]
: R6 g$ n& A; m+ ^2 Uend& G8 z/ ]  \0 Z
下面同样这个问题不明白
' |/ u+ [2 f1 `9 a小妹求大神帮忙!!
) m( m4 k4 w5 p* i7 a8 ?  a9 l
 楼主| 发表于 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-9-14 22:02 , Processed in 0.019168 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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