2 % @brief Computes normalizing constant
using saddle-point method
4 % @author LINE Development Team
8 % @brief Computes normalizing constant
using saddle-point approximation
11 % This function computes the normalizing constant
for cache models
using
12 % the saddle-point method (SPM)
for approximation.
16 % [Z, lZ, xi] = cache_spm(gamma, m)
17 % [Z, lZ, xi] = cache_spm(gamma, m, xi0)
22 % <tr><th>Name<th>Description
23 % <tr><td>gamma<td>Item popularity probabilities
24 % <tr><td>m<td>Cache capacity vector
25 % <tr><td>xi0<td>(Optional) Initial guess
for Lagrange multipliers
30 % <tr><th>Name<th>Description
31 % <tr><td>Z<td>Normalizing constant
32 % <tr><td>lZ<td>Log of normalizing constant
33 % <tr><td>xi<td>Lagrange multipliers
36function [Z,lZ,xi]=cache_spm(gamma,m,xi0)
37gamma=gamma(find(sum(gamma,2)>0),:); %#ok<FNDSB>
42 line_warning(mfilename,
'The number of items equals the cache capacity.\n');
43 Z=cache_erec(gamma,m);
45 xi = cache_xi_iter(gamma,m);
50 xi = cache_xi_iter(gamma,m);
52 xi = cache_xi_iter(gamma,m,xi0);
58 S(k) = S(k) + gamma(k,l) * xi(l);
65 phi = phi + log(1+S(k)) ;
67phi = phi - log(xi) * m';
75 C1=C1+gamma(k,j)/(1+S(k));
79 C2=C2+gamma(k,j)*gamma(k,l)/(1+S(k))^2;
81 C(j,l) = delta(j,l) * C1 - xi(j) * C2;
86Z = exp(phi) * sqrt(2*pi)^(-h) * prod(factorial(m)) / prod(sqrt(xi)) / sqrt(det(C));
87lZ = (-h) * log(sqrt(2*pi)) + (phi) + sum(factln((m))) - sum(log(sqrt(xi))) - log(sqrt(det(C)));
88lZ=real(lZ); % remove small imaginary part roundoffs