koras
koras

Reputation: 15

Monte Carlo - Uniform Distribution

I have this problem:

Each week the three gas stations near your home sell at a price per gallon of X1, X2 and X3, respectively, where Xi are IID uniform random variables on [3.80, 4.20]. You purchase gas at the station with the lowest price. Use simple Monte Carlo methods to estimate average price per gallon of gas that you will pay, with the estimation error no larger than $0.05.

Can someone post an R code for this kind of problem or tell me how to approach this ?

Upvotes: 1

Views: 204

Answers (1)

Severin Pappadeux
Severin Pappadeux

Reputation: 20080

Sure

Lets start with sampling

set.seed(12345)

n <- 1000
stationA <- runif(n, min=3.80, max=4.20)
stationB <- runif(n, min=3.80, max=4.20)
stationC <- runif(n, min=3.80, max=4.20)

whatIpay <- pmin(stationA, stationB, stationC)
avgIpay  <- mean(whatIpay)
stdIpay  <- sd(whatIpay)

now you have to figure out what value of n you need to get within desired error

Upvotes: 2

Related Questions