Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating random numbers that add to 1 in Netlogo

Tags:

netlogo

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!

like image 983
Ale Avatar asked Dec 20 '25 03:12

Ale


1 Answers

Something like this?

let xs n-values 5 [ -> random-float 1 ]
let total sum xs
set xs map [ x -> x / total ] xs
like image 94
Nicolas Payette Avatar answered Dec 21 '25 17:12

Nicolas Payette



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!