如何选择一个随机区域在哪个活动中?
我正在创建一个模型,必须在其中模拟耳机。特别是它的位置将是我在GIS地图上创建的多个区域中的随机位置。我需要运行模型,经过片刻之后,模型必须在我创建的一个区域中在意大利南部生成一个随机的震中位置。此外,这些地区有不同的地震概率(例如,坎帕尼亚20%,卡拉布里亚(Calabria)15%等)。如何改善它?我不知道Java语言,您能指导我吗?非常感谢,问候。我已经上传了我的任何型号的图片。谢谢。
I'm creating a model in which I have to simulate an eartquake. In particular its position would be random within multiple region which I have created on my GIS map. I need to run model and after a few moments, model have to generate a random position of epicenter in South Italy, in one of regions which I created. Moreover, these regions have different probabilities to run an earthquake (for example Campania 20%, Calabria 15%, etc.). How can improve it? I don't know java language as well as, could you guide me on it? Thanks a lot, regards. I've uploaded a pic of my Anylogic model. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MATH.RANDOM()
将返回一个伪数编号(大约)在0(包含)和1(独家)之间的分布(大约)。因此,您可以使用Math.random()<概率
获取true
返回,如果应该发生具有给定概率的事件,并且false
(如果不是)。在这里,一个示例还计算出了地震的实际次数,以表明概率实际上是您所期望的。
预期结果:
您需要在所有地区进行迭代,并将功能应用于每个区域,因为地震不是相互排他性的。如果地震将是相互独家的,那么您的模型/模拟不是很准确。没有什么能阻止在“同一时间”(至少据我所知)发生两次地震,因此您需要对所有地区进行这种概率。当然,当地震发生在附近,如果这种情况实际上是这种情况,您当然也可以建模地震的可能性下降。但这取决于您建模,我不是地震专家。
在这里,一个简单的实现一次,一次检查一次地区的地震。多次执行它,看到有时会产生地震,有时不会产生地震:
Math.random()
will return a pseudorandom number with (approximately) even distribution between 0 (inclusive) and 1 (exclusive). Therefore you can useMath.random() < probability
to gettrue
return if an event with the given probability should happen andfalse
if not.Here an example which also calculates the actual amount of times an earthquake was spawned to show that the probability is actually what you expect.
Expected result:
You would need to iterate over all your regions and apply the function for each region, because earthquakes are not mutual exclusive. If earthquakes would be mutual exclusive your model/ simulation is not very accurate. There is nothing that prevents two earthquakes from happening at the "same time" (at least to my knowledge), so you need to run this probability against all of the regions. You could of course also model something like an decreased probability for an earthquake when an earthquake happens nearby if something like this is actually the case. But that's up to you modelling it, I am no earthquake expert.
Here a simple implementation that checks for an earthquake in a region once. Execute it multiple times to see that sometimes an earthquake will be spawned and sometimes, no earthquake will be spawned: