如何调整以下netlogo代码,以便它实际执行相关的随机游走

时间:2016-08-17 17:12:29

标签: netlogo

在NetLogo中考虑以下用于相关随机游走的代码。它分别从包裹的Cauchy和weibull分布中获取随机转角和随机步长,并执行相关的随机游走。

turtles-own [ orient step ]

  
to-report turning-angle-range [ #min #max ] 
 report #min + random-float ( #max - #min ) 

end 

to-report turning-angles-dist [ #correlation #mean-turning-angle] 

let turning-angle ( ( 1 - #correlation ^ 2) / ( 2 * 180 * ( 1 + (#correlation ^ 2 ) - 2 * #correlation * cos ( ( turning-angle-range 0 180 ) - #mean-turning-angle ) ) ) ) 

 report turning-angle 

end  

to-report weibull-dist [ #shape #scale #mean-step-length ] 

let mean-step-length ( ( #shape / #scale ) * ( ( #mean-step-length / #scale ) ^ ( #shape - 1 ) ) * exp ( ( #mean-step-length / #scale ) ^ ( #shape ) ) ) 

report mean-step-length 

end  

     
to Correlated-Random-Walk 

 ask turtles [

  pen-down

  set orient turning-angles-dist corr-eff mean-turn-angle 

set heading orient 

set step weibull-dist 2 10 mean-move-length 

  fd step 

] 

tick 

end 

我现在遇到的问题是,相关的randomwalk实际上并没有按照应有的方式发生。海龟只是在世界各地的180度垂直线上移动。我猜测应该在每个滴答处选择的随机角度和步长不会发生或者按照它们应该进入步行程序。请帮忙。

1 个答案:

答案 0 :(得分:1)

  1. 粘贴一堆代码时,请确保在复制并粘贴时运行。
  2. 问题与您的想法完全不同。要查看相关内容,请使用以下内容替换Correlated-Random-Walk
  3. to go
      ask turtles [
        pen-down ;but move this to setup
        Correlated-Random-Walk
      ]
      tick
    end
    
    to Correlated-Random-Walk 
      set heading heading + one-of [-1 1] * 10000 * turning-angles-dist corr-eff mean-turn-angle 
      set step weibull-dist 2 10 mean-move-length 
      fd 50 * step 
    end 
    

    唯一的变化是缩放turning-angles-distweibull-dist的结果。