require(ZINO) library(gamlss) library(markovchain) sample <- 30 # DPUT sample initial in each different scenario prop <- runif(1, 0, 1) # Proportion of zeros in the sample of DPUT in each scenario x.zino <- rZINO(n = sample, mu = 12, sigma = 1, nu = prop) # random sample ZINO state <- ifelse(x.zino == 0, "zero", "nonzero") # State definition T <- markovchainFit(data = state, confidencelevel = 0.95)$estimate@transitionMatrix # Transition matrix G <- rmarkovchain( n = 200, object = new("markovchain", transitionMatrix = T) ) # Generate simulated state DPUT A <- replace(G, G == "nonzero", rNO(200, 12, 1)) # replace non-zero values for simulated values normal k <- as.numeric(replace(A, A == "zero", 0)) # replace zeros and make numeric, DPUT # considering lead time=2 remDLT <- matrix(k, nrow = 2) # Group DPUTs during the defined lead time DLT <- remDLT[1, ] + remDLT[2, ] # Jitter lead time demand (LTD) nudlt <- 1 - length(subset(DLT, DLT > 0)) / length(DLT) # Proportion of zeros in the jitter of LTD in each scenario