0

I am using random-gamma with NetLogo. When I add division to the syntax of random-gamma, NetLogo gets an error. The following is an example of calculation syntax using random-gamma. (In addition, these variables "number-dead, S, T" are registered in global variables.) In my simulation it is necessary to add division after random-gamma calculation result. What should I do? Please give some advice to this. We thank you for your cooperation.

set sim precision((number-dead * random-gamma(1 / (S * S))(1 / (T * (S * S)))) / number-dead)3

The following is a popup message when an error occurs.

It is divided by 0. error while observer running / called by procedure GOPARALLEL called by button 'goparallel'

goodgest
  • 418
  • 3
  • 10

1 Answers1

3

I don't think the problem has anything to do with random-gamma. Either S, T, or number-dead are likely to be 0.

If S is 0, then both (1 / (S * S)) and (1 / (T * (S * S))) will result in division by 0.

If T is 0, then (1 / (T * (S * S))) will result in a division by 0.

If number-dead is 0, then (number-dead * random-gamma (1 / (S * S)) (1 / (T * (S * S)))) / number-dead) will result in a division by 0.

Also, I think that code is wrong. It's essentially doing:

let rand random-gamma (1 / (S * S)) (1 / (T * (S * S)))
let raw-num number-dead * rand / number-dead
set sim precision raw-num 3

That is, you're multiplying the result of random-gamma by number-dead, and then immediately dividing the result of that by number-dead, which just leaves you with the result of random-gamma. So I think you may have misplaced some parentheses or something.

Bryan Head
  • 12,360
  • 5
  • 32
  • 50
  • Thank you for your quick advice. I will test it with the code later. Probably it is okay. I might ask you again if I do not understand. Thank you very much. – goodgest Jun 04 '17 at 14:29
  • Hello, I tested it with the recommended code, but the same error has been appeared. "It is divided by 0.". I will think about a bit more. – goodgest Jun 06 '17 at 12:44
  • I didn't recommend any code... I was showing how the code you wrote is probably wrong. – Bryan Head Jun 06 '17 at 14:34
  • Thank you for your pointing out. After that, I am still under review. I will make a new question by combining it with other questions. – goodgest Jun 08 '17 at 07:30