1function Q_RAP_ParsePara2(C,C_name,D,D_name)
2%Q_RAP_ParsePara checks the validity of the input matrices C, D as a
3%representation of RAP. The evaluated conditions are necessary but not
8 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
9 '%s has to be numeric', C_name);
12 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
13 '%s has to be numeric', D_name);
18 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
19 '%s has to be a real matrix', C_name);
22 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
23 '%s has to be a real matrix', D_name);
27if (size(C,1) ~= size(C,2))
28 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
29 '%s is not a square matrix', C_name);
31if (size(D,1) ~= size(D,2))
32 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
33 '%s is not a square matrix', D_name);
35if (size(C,1) ~= size(D,1))
36 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
37 'The matrices %s and %s do not have the same dimension', C_name, D_name);
41if (max(sum(C+D,2)) > 10^(-14)) || (min(sum(C+D,2)) < -10^(-14))
42 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
43 'The matrix %s+%s must have zero row sum', C_name, D_name);
46%check dominant eigenvalue
47if (max(real(eig(C))) > -10^(-14))
48 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
49 'The dominant eigenvalue of the matrix %s must have negative real part', C_name);
51if (max(real(eig(C+D))) > 10^(-14)) || (max(real(eig(C+D))) < -10^(-14))
52 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
53 'The dominant eigenvalue of the matrix %s+%s must have zero real part', C_name, D_name);
56%check non-negative moments
61m1 = -pi*invC*ones(m,1);
63 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
64 'The first moment of the stationary inter-event distribution of the RAP must be non-negative');
66m2 = 2*pi*invC*invC*ones(m,1);
68 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
69 'The second moment of the stationary inter-event distribution of the RAP must be non-negative');
73 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
74 'The variance of the stationary inter-event distribution of the RAP(%s,%s) must be non-negative', C_name, D_name);
76m11 = pi*invC*
P*invC*ones(m,1);
78 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
79 'The first joint moment of two succesive inter-events of the stationary RAP(%s,%s) must be non-negative', C_name, D_name);
82%check non-negative stationary inter-
event density
84limSup = m1 + 10*stdev;
85quantile = pi*expm(C*limSup)*ones(m,1);
87 limSup = limSup + stdev;
88 quantile = pi*expm(C*limSup)*ones(m,1);
92 if( -pi*expm(C*x/numPoints*limSup)*C*ones(m,1) < -10^(-14) )
93 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
94 'The stationaty inter-event density function of the RAP(%s,%s) is negative', C_name, D_name);
98%check non-negative joint density
100limSup = m1 + 5*stdev;
101quantile = pi*expm(C*limSup)*D*expm(C*limSup)*ones(m,1);
102while quantile > 10^-6
103 limSup = limSup + stdev;
104 quantile = pi*expm(C*limSup)*D*expm(C*limSup)*ones(m,1);
109 if( pi*expm(C*x/numPoints*limSup)*D*expm(C*y/numPoints*limSup)*D*ones(m,1) < -10^(-14) )
110 error(
'MATLAB:Q_RAP_ParsePara:InvalidInput',...
111 'The stationary joint inter-event density function of the RAP(%s,%s) is negative', C_name, D_name);