1function [alpha,T] = aph_simplify(a1,T1,a2,T2,p1,p2,pattern)
2 % convolve two ME distributions with parameters a1,T1,a2,T2
3 % The input variable pattern
switch this function to different pattern convolution
4 % p1 and p2 are the specified branch probabilities
for the third pattern (branch)
5 if pattern == 1 % sequence structure
11 alpha = [a1,(1-a1*e1)*a2];
12 T = [T1,(-T1*e1)*a2;zeros(order2,order1),T2];
14 elseif pattern == 2 % parallel strucutre
21 alpha = [kron(a1,a2),(1-a2*e2)*a1,(1-a1*e1)*a2];
22 Tr1 = [kron(T1,eye(order2))+kron(eye(order1),T2),kron(eye(order1),-T2*e2),kron(-T1*e1,eye(order2))];
23 Tr2 = [zeros(order1,order1*order2),T1,zeros(order1,order2)];
24 Tr3 = [zeros(order2,order1*order2),zeros(order2,order1),T2];
27 elseif pattern == 3 % branch structure
32 alpha = [p1*a1,p2*a2];
33 T = [T1,zeros(order1,order2);zeros(order2,order1),T2];
37 %T = [T1(1,1),T1(1,2);-a1(1)*p1*T1(2,2),T1(2,2)-T1(2,2)*a1(2)*p1];