- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
编辑:
其实我意识到我需要的是X的值。让我说得更清楚。假设我知道概率 P = 0.95,因为我想使用两个标准差。我知道 P(-500 < x <500) 的范围,这意味着我知道 y 和 z ,我也知道均值和标准差。如果我想知道 x 的值是多少,我应该使用哪种方法。我找到了一个calculator做这样的事情但无法理解要使用哪个公式。
原始问题:
I want to calculate normal distribution probability of random variables using Java. Was not sure which formula to use to code to solve a problem like this. If I know the value of mean and Standard deviation and want to find the probability of being x's value between 2 certain values y and z (P(-500
谁能帮帮我?
最佳答案
您可以使用 error function , 可用在 org.apache.commons.math.special.Erf
,正如所讨论的here和 here .
附录:@Brent Worden 的 answer 中提出的方法大大简化了此类问题的解决方案。作为一个具体的例子,下面的代码显示了如何解决 examples你指的是哪个。此外,我发现比较定义 here 很有帮助。执行cumulativeProbability()
使用 Erf.erf
.还要注意如何执行 inverseCumulativeProbability()
概括了所需的迭代方法。
import org.apache.commons.math.MathException;
import org.apache.commons.math.distribution.NormalDistribution;
import org.apache.commons.math.distribution.NormalDistributionImpl;
/**
* @see http://stattrek.com/Tables/Normal.aspx#examples
* @see https://stackoverflow.com/questions/6353678
*/
public class CumulativeProbability {
private static NormalDistribution d;
public static void main(String[] args) throws MathException {
// Problem 1; µ = 1000; σ = 100
d = new NormalDistributionImpl(1000, 100);
System.out.println(d.cumulativeProbability(1200));
// Problem 2; µ = 50; σ = 10
d = new NormalDistributionImpl(50, 10);
System.out.println(d.inverseCumulativeProbability(0.9));
}
}
控制台:
0.977249868051820862.81551565546365
讨论:
问题 1. 在具有平均持续 1000 小时且标准差为 100 小时的正态分布生命周期的设备中,~97.7% 会在 1200 小时内失效。
问题 2。在拥有平均重复 50 次且标准差为 10 次重复的正态分布技能的人中,一个人可以超过 90% 的人群,重复 63 次。
关于java - 使用 Java 计算正态分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6353678/
我有一个数字列表,其中包含这些数字的样本平均值和标准差。现在我正在尝试找出平均值+-SD、平均值+-2SD 和平均值+-3SD 中的数字。例如,在mean+-SD部分,我编写了这样的代码: ND1 =
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: erf(x) and math.h Best library for statistics in C++?
我正在尝试模拟球迷到达体育场。系统本身,我相信不会有问题,但是,粉丝的到来是一个正态分布。 我的问题是: 我有一个特定的到达时间,比如 100 分钟和 1000 个粉丝,我需要在该分布之后的某个时间生
在 Julia 中,有人实现了正态分布 pdf 或 cdf 来支持任意精度的 BigFloats。 例如,此代码返回 0.0,而实际上这些值应该略有不同。 x = parse(BigFloat, "2
给定具有上限和下限误差的平均值,计算分割正态分布的最佳方法是什么? 到目前为止我已经: from random import choice, gauss def random_split_normal
我希望用户指定分布的范围 delta、sigma 以及它应该产生的随机值的数量。但是在 Iron Python 中生成具有正态分布的随机值的最佳方法是什么?我在 NumPy 中找到了一个可以执行此操作
我的说明:编写一个程序,开始询问用户正态分布的均值 u 和标准差 s(参见 wiki article) 程序然后要求 N,然后要求 N 个值 x。对于每个 x,它都会将 f(x) 写到屏幕上。请注意,
通用的 Accept 拒绝算法和往常一样。 1 从 Unif[0,1] 生成 U 1 ,U 2 ,U 3 2 X ← −log(U 1 ) 3 if U 2 > exp(−0.5(X − 1) 2 )
我需要计算两条曲线之间的面积。我有很多数据,所以我想以编程方式进行。 基本上,我总是有 2 个正态分布,根据平均值和标准差计算得出。然后我想计算它们相交的程度。这是一个 example我的意思,还有一
我想知道 JavaScript 函数 Math.random 是否使用正态分布(相对于均匀分布)。 如果不是,我怎样才能得到使用正态分布的数字?对于创建随机正态分布数字的算法,我尚未在 Interne
我想在 d3.js 中创建正态分布图(钟形曲线)。 像这样[ http://statwiki.ucdavis.edu/@api/deki/files/73/a9f781e1b0891ceedd50cd
我的教授正在模拟客户到达银行的情况。它表示客户到达时遵循均值 3.5 和标准偏差 1.3 的正态分布。 问题是我很难理解为什么使用这段代码。我相信他提供的代码正在接收一个流、平均值和标准差来生成随机数
我正在生成一些随机数并出现可疑行为。这是我的代码: // initialized earlier... in the constructor of a class boost::mt1
用 ruby 生成正态分布随机数的代码是什么? (注意:我回答了我自己的问题,但我会等几天再接受,看看是否有人有更好的答案。) 编辑: 为此,我查看了两次搜索产生的 SO 上的所有页面: +“正态
我尝试编写 R 代码来查找 mu s.t. 的值。正态分布满足概率 P(N(mu, 1)>1.96)=0.95 (即 P(Z>1.96)=0.95 其中 Z~ N(mu, 1) 和 mu 是我想要得到
我是一名优秀的程序员,十分优秀!