palebluedot
palebluedot

Reputation: 53

Generate random number within a range in NetLogo

I am trying to generate random numbers using the random-poisson function. This function only seems to allow me to give it the mean, while this is OK, I also want to give it a min and max value. For example, if I wanted to create a function that generates a random week number (1-52), with the most likely pick being, say, week 30, how would I create a function in NetLogo that creates a random number that doesn't exceed 52?

Upvotes: 4

Views: 3699

Answers (1)

KOUSHIK MONDAL
KOUSHIK MONDAL

Reputation: 21

Please see if this helps. It is giving pretty good results around 30.

to poisson
  let maxv 52
  let minv 1
  let lamda 30
  let z  minv + random-poisson (lamda - minv)
  show z
end

Let me know how it worked out for you. Thank you.

Upvotes: 1

Related Questions