x = seq(-1.5, 1.5, by = 0.01)
uniform1 = dunif(x, min = -0.25, max = 0.25)
uniform2 = dunif(x, min = -1.00, max = 1.00)
plot(x, uniform1, type = 'l', ylab = 'f(x)', xlab = 'x', main = '2 Uniform Kernels with Different Bandwidths', col = 'red')
lines(x, uniform2, col = 'blue')
legend(0.28, 1.5, c('Uniform(-0.25, 0.25)', 'Uniform(-1.00, 1.00)'), lty = c(1,1), col = c('red', 'blue'), box.lwd = 0)
rug(x)
x <- rbinom(x, 2, 0.5)
plot(density(x), type = "h")
Fx <- pbinom(x, 2, 0.5)
plot(x,Fx)
rug(x)
x<-rexp(1000,1/2)
plot(density(x))
rug(x)
Fx<-pexp(x)
plot(x,Fx)
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.