1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
|
# Plotting a Normal Distribution
par(mfrow = c(1, 3))
x=rnorm(100000, mean=0, sd=2);
d=hist(x, breaks=100, xlim=c(-10,10), ylim=c(0,5000));
x=-1000:1000; x=x/100;
lines(x, dnorm(x, mean=0, sd=2)*20000, col="red", lty=19, lwd=1.5)
plot(d$mids, d$density, type="h", ylim=c(0, 0.25), xlim=c(-10, 10))
lines(x, dnorm(x, mean=0, sd=2), col="red", lty=19, lwd=1.5)
plot(d$mids, d$density, type="p", ylim=c(0, 0.25), xlim=c(-10, 10), col="blue")
lines(x, dnorm(x, mean=0, sd=2), col="red", lty=19, lwd=1.5)
# Plotting a Poison Distribution
par(mfrow = c(1, 3))
x=rpois(100000, lambda = 4);
d=hist(x, breaks=100, xlim=c(0,15), ylim=c(0,25000));
x=0:50;
lines(x, dpois(x, lambda = 4)*100000, col="red", lty=19, lwd=1.5)
plot(d$mids, d$density, type="h", ylim=c(0, 1.2), xlim=c(0, 15))
lines(x, dpois(x, lambda = 4)*5, col="red", lty=19, lwd=1.5)
plot(x, dpois(x, lambda = 4), type="p", ylim=c(0, 0.25), xlim=c(0, 15), col="blue")
lines(x, dpois(x, lambda = 4), col="red", lty=19, lwd=1.5)
|