【发布时间】:2018-02-28 22:56:24
【问题描述】:
也许这个问题太简单了。但下面我展示了一个优化,其中df 和q 是输入,ncp 是输出。
我想知道如何扭转这种优化,以便我可以输入q 和ncp(即,ncp 当前是输出),而不是得到df 作为输出?
df = 30 ; q = 2
f <- function (ncp, alpha, q, df){
abs(suppressWarnings(pt(q = q, df = df, ncp, lower.tail = FALSE)) - alpha)
}
sapply(c(.025, .975),
function(x)optimize(f, interval = c(-20, 20), alpha = x, q = q, df = df)[[1]])
# [1] -0.03931343 4.00808666 # Current output `ncp`, but want to become input#
【问题讨论】:
标签: r function optimization