问题
As the title suggest, would hope to generate a random float in the range between 0.3 < x < 0.7.
I currently using while loop to check a random float whether its in that range. I was wondering whether there is a better method to do this.
Thanks
回答1:
0.3 + random-float 0.4
will give you 0.3 <= x < 0.7.
If you really don't want 0.3, I guess you can always loop that one out. I'm not sure if there is a better way.
来源:https://stackoverflow.com/questions/9805064/how-do-i-generate-a-number-in-the-range-between-0-3-x-0-7-with-netlogo