Created
June 28, 2021 11:20
-
-
Save alexhallam/ff07fe276728151d17f4df2e0658d067 to your computer and use it in GitHub Desktop.
Monte Carlo Addition of Random Variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# calculate the sum of a, b, b2 | |
n <- 1000 | |
m <- 10 | |
a <- rnorm(n, 10) | |
b <- rnorm(n, 20) | |
b2 <- .1*a + .1*b | |
c <- sample(a, size = m*n, replace=T) + sample(b, size = m*n, replace=T) + sample(b2, size = m*n, replace=T) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment