Home > wafo > markov > mctp2reverse.m

# mctp2reverse

## PURPOSE

Calculates the time-reversed MCTP for a SMCTP.

## SYNOPSIS

[Qr,QQ,FF,FFr] = mctp2reverse(F)

## DESCRIPTION

```  MCTP2REVERSE  Calculates the time-reversed MCTP for a SMCTP.

CALL: [Qr] = mctp2reverse(F);
[Qr,QQ,FF,FFr] = mctp2reverse(F);

Qr     = Cell array of min-max and max-min transition
matrices for time-reversed MCTP.           {1x2}
QQ     = Cell array of min-max and max-min transition
matrices for MCTP.                         {1x2}
FF     = From-To matrix calculated from QQ.         [nxn]
FFr    = From-To matrix calculated from Qr.         [nxn]

F{1,1} = min-Max matrix                             [nxn]
F{1,2} = Max-min matrix                             [nxn]

If a matrix F{1,2}=[], then the process will
be assumed to be time-reversible.

Se also```

## CROSS-REFERENCE INFORMATION

This function calls:
 mat2tmat Converts a matrix to a transition matrix. mctp2stat Calculates the stationary distribution for a MCTP. cell Create cell array. error Display message and abort function.
This function is called by:

## SOURCE CODE

```001 function [Qr,QQ,FF,FFr] = mctp2reverse(F)
002 % MCTP2REVERSE  Calculates the time-reversed MCTP for a SMCTP.
003 %
004 % CALL: [Qr] = mctp2reverse(F);
005 %       [Qr,QQ,FF,FFr] = mctp2reverse(F);
006 %
007 % Qr     = Cell array of min-max and max-min transition
008 %          matrices for time-reversed MCTP.           {1x2}
009 % QQ     = Cell array of min-max and max-min transition
010 %          matrices for MCTP.                         {1x2}
011 % FF     = From-To matrix calculated from QQ.         [nxn]
012 % FFr    = From-To matrix calculated from Qr.         [nxn]
013 %
014 % F{1,1} = min-Max matrix                             [nxn]
015 % F{1,2} = Max-min matrix                             [nxn]
016 %
017 % If a matrix F{1,2}=[], then the process will
018 % be assumed to be time-reversible.
019 %
020 % Se also
021
022 % Copyright (c) 1999 by Pär Johannesson
023 % Toolbox: Rainflow Cycles for Switching Processes V.1.0, 2-Oct-1997
024
025 % Check input arguments
026
027 ni = nargin;
028 no = nargout;
029 error(nargchk(1,1,ni));
030
031 % Define
032
033 n = length(F{1,1});  % Number of levels
034
035 % Normalize the rowsums of F{1,1} to 1  ==>  QQ{1,1}
036 % Normalize the rowsums of F{1,2} to 1  ==>  QQ{1,2}
037
038 QQ= cell(1,2);
039
040 QQ{1,1} = F{1,1};      % min-max matrix
041 if isempty(F{1,2})     % Time-reversible?
042   QQ{1,2} = F{1,1}';   % max-min matrix
043 else                   % F{i,2} is given
044   QQ{1,2} = F{1,2};    % max-min matrix
045 end
046
047 QQ{1,1} = mat2tmat(QQ{1,1},1);  % normalize min-max matrix
048 QQ{1,2} = mat2tmat(QQ{1,2},-1); % normalize max-min matrix
049
050 %
051 % Create Transition matrices for time-reversed MCTP
052 %
053
054 Qr = cell(1,2);
055
056 % Calculate stationary distribution of minima and maxima
057 [ro,roh] = mctp2stat(F);
058
059 % Backward min-to-max
060 I1 = find(ro>0); I2 = find(ro<=0);
061 ro_inv = ro; ro_inv(I1) = 1./ro(I1); ro_inv(I2) = zeros(1,length(I2));
062 Qr{1,1} = QQ{1,2}' .* (ro_inv'*roh);
063
064 % Backward max-to-min
065 I1 = find(roh>0); I2 = find(roh<=0);
066 roh_inv = roh; roh_inv(I1) = 1./roh(I1); roh_inv(I2) = zeros(1,length(I2));
067 Qr{1,2} = QQ{1,1}' .* (roh_inv'*ro);
068
069 % Make the frequency matrix FF for the joint min-Max and Max-min
070 % distribution (from Q)
071
072 FF = QQ{1,1}.*(ro'*ones(1,n)) + QQ{1,2}.*(roh'*ones(1,n));
073
074 % Make the frequency matrix FF for the joint min-Max and Max-min
075 % distribution (from Qr)
076
077 FFr = Qr{1,1}.*(ro'*ones(1,n)) + Qr{1,2}.*(roh'*ones(1,n));
078
079```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003