Skip to main content
2 of 6
Added more context
jmutua
  • 373
  • 1
  • 4
  • 12

Monte Carlo simulation

I have an equation to calculate z from multiplying several rasters and numbers as seen below:

z <- a*b*c*d*e

The raster layers and values are as below:

set.seed(234)
r <- rast(nrows=10, ncols=10)

a <- setValues(r,runif(n = 100, min = 4, max=16))
b <- setValues(r,runif(n = 100, min = 0, max=100))
c <- setValues(r,runif(n = 100, min = 68, max=270))
d <- 0.8
e <- 7.9

I need to calculate uncertainty based on varying c and e within the ranges of:

+/- 10 for raster c

+/- 4 for e

I would like to run a Monte Carlo simulation based on values from the two variables selected randomly from within these uncertainty ranges. In the end I need to plot an uncertainty map

jmutua
  • 373
  • 1
  • 4
  • 12