%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Copyright (c) 2004. Takayuki Osogami. All Rights Reserved. % % % % Permission to use, copy, modify, and distribute this source code % % and its documentation for any purpose, without fee, and without % % a written agreement, is hereby granted, provided that the above % % copyright notice, this paragraph and the following two paragraphs % % appear in all copies, modifications, and distributions. % % Created by Takayuki Osogami, Department of Computer Science, % % Carnegie Mellon University. % % % % IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR ANY % % DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS % % SOURCE CODE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN % % ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. % % % % THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, % % BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY % % AND FITNESS FOR A PARTICULAR PURPOSE. THE SOURCE CODE AND % % ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS % % PROVIDED "AS IS." THE AUTHOR HAS NO OBLIGATION TO PROVIDE % % MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Usage: [tau,T] = convolutionofPH(tau1,T1,tau2,T2) % % Given two PH distributions, (tau1,T1) and (tau2,T2), % the function returns the convolution of the two, % which is also a PH distribution (tau,T). % % author: Takayuki Osogami % Department of Computer Science % Carnegie Mellon University % osogami@cs.cmu.edu % date: June 6, 2004 function [tau,T] = convolutionofPH(tau1,T1,tau2,T2) tau0 = 1 - sum(tau1); if( tau0 == 0 ) tau = [tau1,zeros(size(tau2))]; else tau = [tau1,tau0*tau2]; end dim1 = size(T1); e = ones(dim1(1),1); t = - T1 * e; dim2 = size(T2); T = [T1 t*tau2; zeros(dim2(1),dim1(2)) T2 ];