LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
m3pp2m_fitc_theoretical.m
1function [fit] = m3pp2m_fitc_theoretical(mmap, method, t, tinf)
2% Fits the theoretical characteristics of a MMAP(n,m) with a M3PP(2,m).
3% INPUT:
4% - mmap: the MMAP(n,m) to fit with a M3PP(2,m)
5% - method: 'exact_delta', 'approx_delta', 'approx_cov' or 'approx_ag'
6% - t: (optional) finite time scale
7% - tinf: (optional) near-infinite time scale
8
9if nargin == 1
10 method = 'approx_delta';
11end
12
13m = size(mmap,2)-2;
14
15if strcmp(method,'approx_cov') && m > 2
16 error('Approximate covariance fitting only supported for two classes.');
17end
18
19if nargin < 3
20 t1 = 1;
21 t2 = 10;
22 tinf = 1e4;
23 t3 = 10;
24else
25 t1 = t;
26 t2 = t;
27 t3 = t;
28end
29
30% joint-process charactersitics
31a = map_count_mean(mmap,t1)/t1;
32bt1 = map_count_var(mmap,t1)/(a*t1);
33bt2 = map_count_var(mmap,t2)/(a*t2);
34binf = map_count_var(mmap,tinf)/(a*tinf);
35mt2 = map_count_moment(mmap,t2,1:3);
36m3t2 = mt2(3) - 3*mt2(2)*mt2(1) + 2*mt2(1)^3;
37
38% per-class rates
39ai = mmap_count_mean(mmap,1);
40
41if strcmp(method,'exact_delta') == 1 || strcmp(method,'approx_delta') == 1
42 % per-class variance difference
43 dvt3 = zeros(m,1);
44 for i = 1:m
45 mmap2 = {mmap{1},mmap{2},mmap{2+i},mmap{2}-mmap{2+i}};
46 Vt3 = mmap_count_var(mmap2,t3);
47 dvt3(i) = Vt3(1)-Vt3(2);
48 end
49end
50
51if strcmp(method,'exact_delta') == 1
52 fit = m3pp2m_fitc(a, bt1, bt2, binf, m3t2, t1, t2, ai, dvt3, t3);
53elseif strcmp(method,'approx_delta') == 1
54 fit = m3pp2m_fitc_approx(a, bt1, bt2, binf, m3t2, t1, t2, ai, dvt3, t3);
55elseif strcmp(method,'approx_cov') == 1
56 vi = mmap_count_var(mmap,t3);
57 s = 0.5 * (map_count_var(mmap,t3) - sum(vi));
58 fit = m3pp22_fitc_approx_cov(a, bt1, bt2, binf, m3t2, t1, t2, ai, s, t3);
59elseif strcmp(method,'approx_ag') == 1
60 gt3 = zeros(m,1);
61 for i = 1:m
62 mmap2 = {mmap{1},mmap{2},mmap{2+i},mmap{2}-mmap{2+i}};
63 v2t3 = mmap_count_var(mmap2,t3);
64 s2t3 = mmap_count_mcov(mmap2,t3);
65 gt3(i) = v2t3(1) + s2t3(1,2);
66 end
67 fit = m3pp2m_fitc_approx_ag(a, bt1, bt2, binf, m3t2, t1, t2, ai, gt3, t3);
68else
69 error('Invalid method ''%s\''', method);
70end
71
72end