Reputation: 107
I am trying to generate a list of random numbers that must all add to 1 (or 100 if that's easier) but can't figure out how to do it. I know Netlogo allows you to create random numbers but can't find a way to set the rule that the addition of the generated numbers must be 1. Any help is much appreciated!
Upvotes: 3
Views: 94
Reputation: 14972
Something like this?
let xs n-values 5 [ -> random-float 1 ]
let total sum xs
set xs map [ x -> x / total ] xs
Upvotes: 4