LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
qsys_mginf.m
1function varargout=qsys_mginf(lambda,mu,varargin)
2% [L,Lq,W,Wq,p0]=QSYS_MGINF(LAMBDA,MU)
3% [L,Lq,W,Wq,p0,pk]=QSYS_MGINF(LAMBDA,MU,K)
4%
5% Exact solution for M/G/∞ queue (infinite servers).
6% Performance is independent of the service time distribution shape (G).
7% The number of customers in the system follows a Poisson distribution.
8%
9% Input:
10% lambda - arrival rate
11% mu - service rate (mean service time = 1/mu)
12% K (optional) - state for probability computation
13%
14% Output:
15% L - average number of customers in system
16% Lq - average number of customers in queue (always 0)
17% W - average time in system (= 1/mu)
18% Wq - average waiting time in queue (always 0)
19% p0 - probability of empty system
20% pk (optional) - probability of exactly k customers in system
21
22rho = lambda / mu;
23
24% Exact results for M/G/∞
25L = rho; % Average number of customers = average busy servers
26Lq = 0; % No queue since infinite servers
27W = 1 / mu; % Average time = service time (independent of arrival process)
28Wq = 0; % No waiting time
29p0 = exp(-rho); % Empty system probability (Poisson distribution)
30
31% Always return 5 outputs
32varargout{1} = L;
33varargout{2} = Lq;
34varargout{3} = W;
35varargout{4} = Wq;
36varargout{5} = p0;
37
38% If k is provided, compute and return P(k customers in system)
39if nargin >= 3
40 k = varargin{1};
41 pk = exp(-rho) * rho^k / factorial(k);
42 varargout{6} = pk;
43end
44end