我正在尝试绘制对数刻度,但我不断收到此错误:
Error in plot.window(...) : invalid "log=1/h" specification.
我不确定我做错了什么。下面是我的代码:
#function
function(stepsize, temp_val, counter) {
while(counter < 0) {
counter <- counter + stepsize
px_norm <- dnorm(counter, mean = 0, sd = .04)
temp_val <- temp_val + px_norm }
temp_val <- 2*temp_val
temp_val <- temp_val *(stepsize/2)
print(temp_val, digits = 12)
}
#Initial step size
h <- .01
while (h > .00001) {
x <- calc_error(h, 0, -5) #Gives me a result around .5
err <- x - (exp(-.02)*0.5)
plot(1/h, err, log = "1/h")
h <- h/10 }
基本上,在我试图展示的这个简短函数中,随着步长的增加,真实答案的误差会减少。但是,我在绘制这个时遇到了麻烦。任何帮助将不胜感激。谢谢