1

I am getting the following error when I run my code: "math operation produced a non-number"

I know that it may happen when in the formula a ^ b a is negative and b is fractional.

Mine are

  1. (1 + (1 / a)*(1 - b)^(1 / a))
  2. (1 + a)*(1 - b)^(a))

where a can vary from 0.1 to 1 and b may be defined as 1) a random-normal 0.1 0.1 (a random value between 0 and 0.2), or 2) random-normal 0.8 0.2 (a random value between 0.6 and 1).

However, I cannot understand what I am doing wrong. The formula that I use is correct. Can it be the random value that I am computing?

  • 1
    `random-normal 0.1 0.1` does not choose a number between 0 and 0.2, it chooses a number from the normal distribution with mean of 0.1 and standard deviation of 0.1. That can be negative. Try typing`random-normal 0.1 0.1` multiple times into the command center and see what it returns. – JenB Oct 05 '19 at 07:46
  • Thank you. I thought that selecting a number from that normal distribution, being standard deviation 0.1, it could be minimum 0 –  Oct 05 '19 at 10:12
  • This is how I edited the code: `random-float 0.2` and `0.6 + random-float 0.2` –  Oct 05 '19 at 10:18
  • Yes, those will get the intervals 0-0.2 and 0.6-0.8, but they are uniform distributions (all numbers in the range have equal probability of being selected). If you want the normal distribution shape but trimmed so it falls within an interval, then you can to that by drawing from the distribution repeatedly until you get one in the desired range. – JenB Oct 05 '19 at 13:27
  • I am sorry but it is not so clear to me how to do what you are suggesting... –  Oct 05 '19 at 18:44
  • What shaped random distribution do you actually want? Or do you not care about the shape, just that the number falls within the correct range? – JenB Oct 05 '19 at 19:54
  • I do not care about the shape, I was looking for a normal distribution with number falls within the correct range with means 0.8 and 0.1 –  Oct 06 '19 at 23:41
  • see https://stackoverflow.com/questions/20230685/netlogo-how-to-make-sure-a-variable-stays-in-a-defined-range/20233830 – Seth Tisue Oct 09 '19 at 01:51

0 Answers0