4 % @brief RECAL (REcursive CALculation) method
for normalizing constant.
10 % @brief RECAL (REcursive CALculation) method
for normalizing constant.
11 % @fn pfqn_recal(L, N, Z, m0)
12 % @param L Service demand matrix.
13 % @param N Population vector.
14 % @param Z Think time vector (
default: zeros).
15 % @param m0 Initial multiplicity vector (default: ones).
16 % @return G Normalizing constant.
17 % @return lG Logarithm of normalizing constant.
20function [G,lG]=pfqn_recal(L,N,Z,m0)
21% [G,logG]=PFQN_RECAL(L,N,Z,M0)
22[M_original,R] = size(L);
24 m0=ones(1,M_original);
30% Detect and consolidate replicated stations
31[L, ~, ~, ~, mapping] = pfqn_unique(L);
34% Combine user-provided m0 with detected multiplicity
35% For each unique station j, sum the m0 values of all original stations mapping to it
36m0_combined = zeros(1, M);
38 m0_combined(mapping(i)) = m0_combined(mapping(i)) + m0(i);
43G_1 = ones(1,nchoosek(Ntot+(M+1)-1,Ntot));
45 I_1=multichoose(M+1,Ntot);
50 I=multichoose(M+1,(Ntot+1)-(n+1));
54 G(i)=Z(r)*G_1(matchrow(I_1(:,1:M),mZ))/nr;
57 G(i)=G(i)+(m(jst)+m0(jst)-1)*L(jst,r)*G_1(matchrow(I_1,m))/nr;