source('https://myweb.uiowa.edu/pbreheny/7110/f20/notes/fun.R')

# Example of generalized inverse
X <- rbind(1:3, 2*(1:3), c(1,0,1))
solve(X)
MASS::ginv(X)
X
X %*% MASS::ginv(X) %*% X

# Conditional independence / precision matrix
n <- 100000
x <- rnorm(n)
y <- x + rnorm(n)
z <- y + rnorm(n)

cor(cbind(x, y, z))
solve(cor(cbind(x, y, z)))
