1function [Pmarg, logPmarg] = getProbMarg(self, ist,
jobclass, state_m)
2% [PMARG, LOGPMARG] = GETPROBMARG(IST, JOBCLASS, STATE_M)
4% Probability distribution
for queue length of a SINGLE
class at a station.
5% Returns
P(n jobs of
class r)
for n=0,1,...,N(r).
7% Compare with getProbAggr: returns probability of a specific per-
class
8% distribution, e.g.,
P(2
class-1, 1
class-2) as a scalar.
13% state_m - (optional) Specific states to query, or [] for all
16% Pmarg - Vector where Pmarg(n+1) =
P(n jobs of this class)
17% logPmarg - Log probabilities for numerical stability
20 line_error(mfilename,'getProbMarg requires station and job class parameters.');
28 line_error(mfilename,'Station number exceeds the number of stations in the model.');
31 line_error(mfilename,'Job class index exceeds the number of
classes in the model.');
34if isempty(self.result)
40 switch self.options.method
42 % Use MVALDMX to get exact marginalized probabilities
43 if ~all(sn.nservers == 1)
44 line_error(mfilename,'MVALDMX exact marginalized probabilities require single-server stations.');
51 S = ones(sn.nstations, 1);
54 [~, ~, ~, ~, ~, Pc] = pfqn_mvaldmx(lambda, D, N, Z, mu, S);
56 % Extract marginal probabilities for the specific station and class
57 % Use the station probabilities from MVALDMX and marginalize for the specific class
58 Q = self.result.Avg.Q;
62 % Create probability vector for this class at this station using binomial approximation
63 Pmarg = zeros(1, nVal + 1);
64 logPmarg = zeros(1, nVal + 1);
67 % Binomial probability with mean qVal
68 logPk = nchoosekln(nVal, k) + k * log(qVal / nVal) + (nVal - k) * log(1 - qVal / nVal);
69 Pmarg(k + 1) = exp(logPk);
70 logPmarg(k + 1) = logPk;
73 % Filter based on state_m if provided
75 if max(state_m) > length(Pmarg) - 1
76 line_error(mfilename,'Requested state exceeds maximum population for this class.');
78 Pmarg = Pmarg(state_m + 1); % +1 for MATLAB indexing
79 logPmarg = logPmarg(state_m + 1);
83 line_error(mfilename,'Failed to compute marginalized probabilities using MVALDMX: %s', ME.message);
87 % Use binomial approximation similar to getProbAggr but for single class
88 Q = self.result.Avg.Q;
92 % Create probability vector for this class at this station
93 Pmarg = zeros(1, nVal + 1);
94 logPmarg = zeros(1, nVal + 1);
97 % Binomial probability with mean qVal
98 % Rainer Schmidt, "An approximate MVA ...", PEVA 29:245-254, 1997
99 logPk = nchoosekln(nVal, k) + k * log(qVal / nVal) + (nVal - k) * log(1 - qVal / nVal);
100 Pmarg(k + 1) = real(exp(logPk));
101 logPmarg(k + 1) = logPk;
104 % Filter based on state_m if provided
106 if max(state_m) > length(Pmarg) - 1
107 line_error(mfilename,'Requested state exceeds maximum population for this class.');
109 Pmarg = Pmarg(state_m + 1); % +1 for MATLAB indexing
110 logPmarg = logPmarg(state_m + 1);
114 line_error(mfilename,'getProbMarg not yet implemented for models with open
classes.');