I’m trying to plot a logarithmic scale, but I keep on getting this error:
Error in plot.window(...) : invalid "log=1/h" specification.
I’m not sure what I am doing wrong. Below is my code:
#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 }
Basically, in this short function I’m trying to show as the step size increases, the error from the real answer will decrease. However, I’m having trouble plotting this. Any help will be appreciated. Thanks
This should be an easy way to create the plot: