LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getProbAggr.m
1function [Pnir,logPnir] = getProbAggr(self, ist)
2% [PNIR,LOGPNIR] = GETPROBAGGR(IST)
3%
4% Probability of a SPECIFIC per-class job distribution at a station.
5% Returns P(n1 jobs of class 1, n2 jobs of class 2, ...) for current state.
6%
7% Compare with getProbMarg: returns total queue-length distribution,
8% i.e., P(n total jobs) summed over all class combinations.
9%
10% Input:
11% ist - Station index
12%
13% Output:
14% Pnir - Scalar probability in [0,1]
15% logPnir - Log probability for numerical stability
16
17if nargin<2 %~exist('ist','var')
18 line_error(mfilename,'getProbAggr requires to pass a parameter the station of interest.');
19end
20if ist > sn.nstations
21 line_error(mfilename,'Station number exceeds the number of stations in the model.');
22end
23if isempty(self.result)
24 self.run;
25end
26Q = self.result.Avg.Q;
27sn = self.getStruct;
28N = sn.njobs;
29if all(isfinite(N))
30 state = sn.state{sn.stationToStateful(ist)};
31 [~, nir, ~, ~] = State.toMarginal(sn, ist, state);
32 % Binomial approximation with mean fitted to queue-lengths.
33 % Rainer Schmidt, "An approximate MVA ...", PEVA 29:245-254, 1997.
34 logPnir = 0;
35 for r=1:size(nir,2)
36 logPnir = logPnir + nchoosekln(N(r),nir(r));
37 logPnir = logPnir + nir(r)*log(Q(ist,r)/N(r));
38 logPnir = logPnir + (N(r)-nir(r))*log(1-Q(ist,r)/N(r));
39 end
40 Pnir = real(exp(logPnir));
41else
42 line_error(mfilename,'getProbAggr not yet implemented for models with open classes.');
43end
44end