paroussisc / stats

Repo to track the material I cover on Wednesdays
MIT License
1 stars 0 forks source link

Core Statistics - Chapter 1 - Exercises #6

Open paroussisc opened 6 years ago

paroussisc commented 6 years ago

Solutions to the Chapter 1 exercises.

paroussisc commented 6 years ago

screenshot from 2018-09-26 11-23-14

paroussisc commented 6 years ago

20180926_112048

(Click images for portrait orientation)

paroussisc commented 6 years ago

This section is reserved for 1.3, which is in my notepad at work!

paroussisc commented 6 years ago

screenshot from 2018-09-26 11-27-50

paroussisc commented 6 years ago

screenshot from 2018-09-26 11-28-37

paroussisc commented 6 years ago

Screenshot from 2019-04-03 13-27-06

paroussisc commented 6 years ago

screenshot from 2018-09-26 11-36-59

paroussisc commented 6 years ago

Using this formula for the conditional Gaussian density:

20180926_145937

The joint density is worked out and then the values are subbed in to create the conditional distribution:

20180926_150019

paroussisc commented 6 years ago

screenshot from 2018-09-26 17-26-30

20180926_160730

paroussisc commented 6 years ago

screenshot from 2018-09-26 17-26-42

20180926_172524

paroussisc commented 6 years ago

screenshot from 2018-09-27 09-11-28 20180927_080258

paroussisc commented 6 years ago

screenshot from 2018-09-27 09-11-37

paroussisc commented 6 years ago

screenshot from 2018-09-27 09-11-46 20180927_082227

paroussisc commented 6 years ago

screenshot from 2018-09-27 09-12-02 screenshot from 2018-09-27 09-12-08

paroussisc commented 6 years ago

20181003_091713

20181003_091732

paroussisc commented 6 years ago
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"))

clt_1