-1
我有一個我想要轉換爲線段的10個概率列表,因此我可以執行輪盤選擇。我如何轉換爲線段?netlogo將概率轉換爲行值
概率列表: [0.17 0.15 0.14 0.14 0.11 0.1 0.06 0.06 0.04 0.03]
當轉換成線段應該是: [0.17 0.32 0.46 0.60 0.71 0.81 0.87 0.93 0.97 1.0]
現在這是我的代碼:
to calculate-s
let i 1 ;; previously added a 0 to list using set p-list fput 0 p-list
while [i < 11] [
ask turtles [
if [p] of self = item i p-list [
let s (p + item (i - 1) p-list)
]
]
set i (i + 1)
]
end
但是,當然,這只是總結了當前的概率和前一個,所以我得到: [0.17 0.32 0.29 0.28 etc]
看起來是http://stackoverflow.com/questions/33570658/how-make-a-list-of-cumulative-sum-in-netlogo的副本 – Alan