You are on page 1of 3

Simulation Techniques CA 2

By
Name - K S Sudharshan
USN – 19BSR18040

set.seed(1729)
# Generate 100 values
returns = rnorm(1:100, mean = 9, sd = 12)
# plot a histogram
hist(returns)

sample(returns,size = 4)
sample(returns,size = 4)
X = matrix(ncol = 4,nrow = 10000)
for(year in 1:4) {
# for each year sample the return 10000 times
for(i in 1:10000){
X[i,year] = sample(returns,1)
}
}

# show first 6 rows


head(X)
# Mean expected rate of return
apply(X,2,mean)

hist(X)

# Queueing Network

library(queueing)
# set queue model input parameters
input<-NewInput.MM1(lambda = 3, mu = 5.3, n = 0)
# creating queue model
output<- QueueingModel(NewInput.MM1(lambda = 3, mu = 5.3, n = 0))
# get the model report
Report(output)

# summary of your model


summary(output)
# Poisson distribution for the arrival process
curve(dpois(x, input$lambda),
from = 0,
to = 20,
n = 21,
xlab = 'Number of Customers',
ylab = 'Prob Dist. for Arrival Process',
lwd = 3,
type = 'b',
ylim = c(0, 0.25),
col = 'red',
main = 'Poisson Distribution for Arrival'
)
# exponential distribution for service process
curve(dexp(x, rate = input$mu),
from = 0,
to = 5,
type = "l",
lwd = 2,
xlab = "Service Waiting Time",
ylab = "Probaility",
col = "red",
main = "Exponential Distribution for Service Process",
ylim = c(0, 1))
abline(h = 0)
As the code is successfully run and gave a desired output by installing the packages and the
Output of histogram, poison distribution, Exponential Distribution have given output.

You might also like