How to generate multiple matrix in R

前端 未结 3 597
一生所求
一生所求 2021-01-27 06:22

I have gotten two lists of values in R.

daily_max_car: (List 1)
21 21 22 22 22 22 21 
daily_0.8: (List 2)
16 17 17 17 18 17 17 
3条回答
  •  花落未央
    2021-01-27 06:44

     Lambda <- 21
     Mue <- 4
     Rho <- Lambda/Mue
     N <- 19
    
    matrix1 <- matrix(0,Lambda,4)
    matrix1[,1] <- 1:Lambda
    rep.row<-function(x,y)
    {
    matrix(rep(x,each=y),nrow=y)
    }
    created_mar_1 <- rep.row(N,Lambda)
    car_n<- created_mar_1-matrix1[,1]
    created_mar_3 <- rep.row(69*60*24,Lambda)
    calculatewq(7)
    
    calculatewq <- function(c)
    {
    P0inv <- (Rho^c*(1-((Rho/c)^(N-c+1))))/(factorial(c)*(1-(Rho/c)))
    for (i in 1:c-1) 
    {
    P0inv = P0inv + (Rho^i)/factorial(i)
    }
    P0 = 1/P0inv
    Lq = (Rho^(c+1))*(1-((Rho/c)^(N-c+1))-((N-c+1)*(1-(Rho/c))*((Rho/c)^(N-   c))))*P0/(factorial(c-1)*(c-Rho)^2)
    Wq = 60*Lq/Lambda
    Ls <- Lq + Rho
    Ws <- 60*Ls/Lambda
    PN <- (Rho^N)*P0/(factorial(c)*c^(N-c))
    customer_serviced <- (1 - PN)*100
    a <- cbind(Lq,Wq,Ls,Ws,customer_serviced)
    return(a)
    }
    for (i in 1:Lambda)
    {
    matrix1[i,2] <- calculatewq(i)[2]
    matrix1[i,3] <- calculatewq(i)[5]
    matrix1[,4] = car_n*created_mar_3
    }
    

提交回复
热议问题