gpt4 book ai didi

java - 智能算法在范围内随机化 Double 但有赔率

转载 作者:行者123 更新时间:2023-12-05 09:01:37 27 4
gpt4 key购买 nike

我使用以下函数生成特定范围内的随机 double 值:

nextDouble(1.50, 7.00)

但是,我一直在尝试提出一种算法,使随机化生成接近 1.50 的 double 的概率高于生成接近 7.00 的 double 的概率。但我什至不知道它从哪里开始。想到什么了吗?

也欢迎使用 Java。

最佳答案

你应该从发现什么开始probability distribution你需要。根据您的要求,并假设随机数生成是独立的,可能是 Poisson distribution是你要找的:

a call center receives an average of 180 calls per hour, 24 hours a day. The calls are independent; receiving one does not change the probability of when the next one will arrive. The number of calls received during any minute has a Poisson probability distribution with mean 3: the most likely numbers are 2 and 3 but 1 and 4 are also likely and there is a small probability of it being as low as zero and a very small probability it could be 10.

通常的概率分布已经在库中实现,例如org.apache.commons.math3.distribution.PoissonDistribution in Apache Commons Math3 .

关于java - 智能算法在范围内随机化 Double 但有赔率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73010282/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com