[英]pth Quantile of Standard Normal Distribution - R
I'm learning statistics and R from a book called "Discovering Statistics using R"... Although it's very informative, it seems to skip over areas even though it suggests no prior knowledge of statistics or R is needed. 我正在从一本名为“使用R发现统计信息”的书中学习统计信息和R ...尽管它非常有用,但它似乎跳过了某些领域,即使它暗示不需要统计知识或R也不需要。 So to the problem:
所以问题来了:
How can you calculate in R the pth quantile of the Standard Normal Distribution using the Dichotomy (or division in halves) method? 如何使用二分法 (或二等分法)在R中计算标准正态分布的p分位数? (and assuming no use of
qnorm()
). (并且假设不使用
qnorm()
)。 that is: 那是:
pnorm(x) = p
pnorm(x)-p = 0
f (x) = 0
Update: 更新:
Dichotomy is a method where you take an interval [a,b]
which takes values of different signs at the end points of the interval and has a single root x
within [a,b]
. 二分法是采用间隔
[a,b]
的方法,该间隔在间隔的端点采用不同符号的值,并且在[a,b]
内具有单个根x
。 You then half if to find F(x1)
, and if f(x1) != 0
it gives you [a,x1]
and [x1,b]
... where the sequence x1, x2,...,
converges to 0
. 然后,如果找到
F(x1)
,则一半,如果f(x1) != 0
它将得到[a,x1]
和[x1,b]
...,其中x1, x2,...,
的序列收敛为0
。
Clumsy, but this works: 笨拙,但这可行:
tolerance <- 1e-6
interval <- c(-1000,1000)
quantile <- 0.2
while(interval[2]-interval[1] > tolerance) {
cat('current interval: ',interval,'\n')
interval.left <- c(interval[1],mean(interval))
interval.right <- c(mean(interval),interval[2])
if(sum(sign(pnorm(interval.left)-quantile))==0) {
interval <- interval.left
} else {
interval <- interval.right
}
}
mean(interval)
qnorm(quantile)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.