density with the bar graph.
- \({f(x) = e^{-x}}\) on [0,infinity) (but just do it on [0, 10]).
set.seed(1230)
x<-runif(1000, 0.0, 10.0)
data<-1/exp(x)
rdata = matrix(data, nrow = 1000, ncol = 1)
hist(rdata,probability=TRUE)

set.seed(1230)
hist(rexp(1000,1),probability=TRUE)

- \({f(x) = 2x}\) on [0, 1].
set.seed(1230)
x<-runif(1000, 0.0, 1.0)
rdata = matrix(2*x, nrow = 1000, ncol = 1)
hist(rdata,probability=TRUE)

set.seed(1230)
plot(density(2*runif(1000,0.0,1.0)),probability=TRUE)

- \({f(x) = 3x^{2} }\), on [0, 1].
set.seed(1230)
x<-runif(1000, 0.0, 1.0)
rdata = matrix(3*x^2, nrow = 100, ncol = 1)
hist(rdata,probability=TRUE)

set.seed(1230)
plot(density(3*runif(1000,0.0,1.0)^2),probability=TRUE)

- \({f(x) = \text{ 4 |x - 0.5|}}\), on [0, 1].
set.seed(1230)
x<-runif(1000, 0.5, 1.0)
y<-runif(1000, 0.0, 1.5)
datax<-4*(x-0.5)
datay<-4*(0.5-y)
rdata = matrix(datax,datay, nrow = 1000, ncol = 2)
hist(rdata,probability=TRUE)

set.seed(1230)
x<-4*(runif(1000,0.5,1.0)-0.5)
y<-4*(0.5-runif(1000,0.0,0.5))
rdata = matrix(datax,datay, nrow = 1000, ncol = 2)
plot(density(rdata),probability=TRUE)
