How do I generate a number in the range between 0.3 < X < 0.7 with netlogo

▼魔方 西西 提交于 2019-12-13 07:04:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!