Open paroussisc opened 6 years ago
(Click images for portrait orientation)
This section is reserved for 1.3, which is in my notepad at work!
Using this formula for the conditional Gaussian density:
The joint density is worked out and then the values are subbed in to create the conditional distribution:
library(ggplot2)
# names of the files for the GIF
png(file = "clt%02d.png",
width = 200,
height = 200)
# create plots for exponentially increasing sample size
for (n in 1:15)
{
sq <- seq(0.0, 30, 1)
x_p <- data.frame(x = sq, y = dpois(sq, n))
x_p$dist <- "pois"
x_n <- data.frame(x = sq, y = dnorm(sq, n, sqrt(n)))
x_n$dist <- "normal"
x <- rbind(x_p, x_n)
# plot distribution of sample
print(ggplot(x) + geom_line(aes(x=x, y=y, colour = dist)) )
}
dev.off()
system("convert -delay 50 *.png clt_1.gif")
file.remove(list.files(pattern = ".png"))
Solutions to the Chapter 1 exercises.