Distributions Part 2
Click here to open the slides. Univariate distribution relationships. Essence of calculus video series.
Here is the R code from class:
n <- 5
p <- 0.35
# p <- .65
probs <- dbinom(0:n, n, p)
probs
sum(probs)
barplot(dbinom(0:n, n, p), names.arg=0:n)
x <- rnorm(100)
ggplot(data.frame(x = x), aes(x = x)) +
geom_histogram(bins = 10, fill = 'grey70') +
geom_vline(xintercept = mean(x), color = 'blue') +
geom_vline(xintercept = c(mean(x) - sd(x), mean(x) + sd(x)), color = 'darkgreen')
ggplot(data.frame(x = x), aes(x = x)) +
geom_histogram(aes(y = ..density..), bins = 10, fill = 'grey70') +
geom_vline(xintercept = mean(x), color = 'blue') +
geom_function(fun = dnorm) +
geom_vline(xintercept = c(mean(x) - sd(x), mean(x) + sd(x)), color = 'darkgreen')