18/11/27 11:23:34.49 WzO5TT32.net
draft
.lambda=1/20
.mu=1/10
.s=1
MMS = function(n, lambda=.lambda ,mu=.mu,s=.s){
rho=lambda/mu
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
}
now8=function(x){
p=0
for(i in 0:x) p=p+MMS(i,s=x)
}
1-now8(1)
E=0
for(i in 0:1e4) E=E+i*MMS(i)
E*(1/.mu)
n=(1:10)[which.max(sapply(1:10,now8)>0.9)]
now8(n)