Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking probabilities and random numbers (NetLogo)

I'm writing to have an explanation about checking probabilities in a model built by NetLogo. I have a circumstance that can happen with a probability, for example, of 60%... Thus I generate a number with

let trial random 100

So, it's not clear to me if I have to verifiy that trial is greater than 60 or lower equal than 60, so that the probability is satisfied.

Which is the correct way? Thank you

like image 263
SagittariusA Avatar asked Feb 24 '26 13:02

SagittariusA


1 Answers

You need to check if the result is less than the probability (not less than or equal). For example:

if random 100 < 60 [
  do-something
]

Using random 100 will give you a number between 0 and 99 (inclusive). In the example, numbers 0 to 59 will meet the condition, i.e., 60 numbers out of the 100 possible numbers: a 60% probability.

like image 71
Nicolas Payette Avatar answered Feb 26 '26 07:02

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!