LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cache_miss.m
1%{ @file cache_miss.m
2 % @brief Cache miss rate computation
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes miss rates for a cache system
9 %
10 % @details
11 % This function computes various miss rate metrics for a cache system
12 % with given item popularity distribution and cache capacity.
13 %
14 % @par Syntax:
15 % @code
16 % [M,MU,MI,pi0] = cache_miss(gamma, m)
17 % [M,MU,MI,pi0] = cache_miss(gamma, m, lambda)
18 % @endcode
19 %
20 % @par Parameters:
21 % <table>
22 % <tr><th>Name<th>Description
23 % <tr><td>gamma<td>Item popularity probabilities
24 % <tr><td>m<td>Cache capacity
25 % <tr><td>lambda<td>(Optional) Arrival rates per user per item
26 % </table>
27 %
28 % @par Returns:
29 % <table>
30 % <tr><th>Name<th>Description
31 % <tr><td>M<td>Global miss rate
32 % <tr><td>MU<td>Per-user miss rate
33 % <tr><td>MI<td>Per-item miss rate
34 % <tr><td>pi0<td>Per-item miss probability
35 % </table>
36 %
37 % @see cache_erec
38%}
39function [M,MU,MI,pi0]=cache_miss(gamma,m,lambda)
40% M: global miss rate
41% MU: per-user miss rate
42% MI: per-item miss rate
43% pi0: per-item miss probability
44ma=m; ma(1)=ma(1)+1;
45M = cache_erec(gamma,ma) / cache_erec(gamma,m);
46if nargin>2
47 u=size(lambda,1);
48 n=size(lambda,2);
49 MU=zeros(u,1);
50 for v=1:u
51 for k=1:n
52 pi0(k) = cache_erec(gamma(setdiff(1:n,k),:),m) / cache_erec(gamma,m);
53 MU(v) = MU(v) + (lambda(v,k,1))*pi0(k);
54 end
55 end
56 MI=zeros(n,1);
57 for k=1:n
58 MI(k) = MI(k) + sum(lambda(:,k,1))*pi0(k);
59 end
60end
61end