{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

MM1 Q Math C&D exampmle

# MM1 Q Math C&D exampmle - t< Td Nd< Nd 1 n< n 1...

This preview shows pages 1–3. Sign up to view the full content.

#***************** #****Tutorial **** #***************** ## MM1 Code MM1 <- function(ArriveRate,DepartRate,random) { cat("WELCOME TO THE C&D","\n") cat("\n") Na <- 0 Nd <- 0 n <- 0 t <- 0 To <- 7.5-ArriveRate*log(random[1]) random <- random[2:length(random)] infinit <- 1000000 Td <- infinit Ta <- To T <- 8.5 flag <- 1 ArrivalTime <- Ta DepartureTime <- NULL Q=NULL while (flag>=1) { flag1<-0 flag2<-0 flag3<-0 if (Ta <= Td & Ta <= T) { t <- Ta Na <- Na + 1 n <- n + 1 cat("Arrival at time, ",Ta,"\n") Q <- rep(1,length(Q)+1) Ta <- t - ArriveRate*log(random[1]) random <- random[2:length(random)] if (Ta < T) { ArrivalTime <- cbind(ArrivalTime, Ta) }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
if (n==1) { Td <- t - DepartRate*log(random[1]) random <- random[2:length(random)] DepartureTime <- cbind(DepartureTime, Td) } flag1 <- 1 } else if (Td <= Ta & Td <= T)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { t <- Td Nd <- Nd + 1 n <- n - 1 if (n>0) { cat("Departure at time, ",Td,"\n") Td <- t - DepartRate*log(random[1]) random <- random[2:length(random)] DepartureTime <- cbind(DepartureTime, Td) Q <- Q[2:length(Q)] } else { cat("Departure at time, ",Td,"\n") Td <- infinit Q <-NULL } flag2<-1 } else if (min(Ta,Td)>T & n>0) { t <- Td Nd <- Nd + 1 n <- n - 1 if (n>0) { cat("Departure at time, ",Td,"\n") Td <- t - DepartRate*log(random[1]) random <- random[2:length(random)] DepartureTime <- cbind(DepartureTime, Td) Q <- Q[2:length(Q)] } else { cat("Departure at time, ",Td,"\n") Td <- infinit Q <-NULL } flag3<-1 } flag <- flag1+flag2+flag3 cat("The Q is. ..",Q,"\n") ANSWER <- readline(" ") #stall program } return(DepartureTime-ArrivalTime) } output<-MM1(0.1,0.2,runif(500))...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

MM1 Q Math C&D exampmle - t< Td Nd< Nd 1 n< n 1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online