Home > wafo > markov > tr_p2x.m

# tr_p2x

## PURPOSE

Transform P-matrix to X-vector

## SYNOPSIS

[X,r] = tr_p2x(P,trans)

## DESCRIPTION

```  TR_P2X  Transform P-matrix to X-vector

Transforms a transition matrix P to a vector X containing
all elements in P except the diagonal of P.

CALL: [X,r] = tr_p2x(P,trans)

X     = Vector of length n=r*(r-1).    [nx1]
r     = size of P-matrix.

P     = transition matrix.             [rxr]
trans = 0: No transformation. (default)
1: log-odds-transformation.
y = log(x/(1-x))

## CROSS-REFERENCE INFORMATION

This function calls:
 error Display message and abort function. num2str Convert number to string. (Fast version)
This function is called by:
 estsmctp Estimate SMCTP model from an observed rainflow matrix.

## SOURCE CODE

```001 function [X,r] = tr_p2x(P,trans)
002 % TR_P2X  Transform P-matrix to X-vector
003 %
004 % Transforms a transition matrix P to a vector X containing
005 %   all elements in P except the diagonal of P.
006 %
007 % CALL: [X,r] = tr_p2x(P,trans)
008 %
009 % X     = Vector of length n=r*(r-1).    [nx1]
010 % r     = size of P-matrix.
011 %
012 % P     = transition matrix.             [rxr]
013 % trans = 0: No transformation. (default)
014 %         1: log-odds-transformation.
015 %              y = log(x/(1-x))
016 %
018
019
020 if nargin<2, trans=[]; end
021 if isempty(trans), trans=0; end
022
023 r = length(P);
024 E= eye(r);
025 EE = E(:);
026 IE = find(EE==0);
027 PP = P';
028 X = PP(:);
029 X = X(IE);
030
031 switch trans
032
033 case 0  % No transformation
034
035 case 1  % log-odds-transformation
036
037   X = logOdds(X);
038
039 otherwise
040
041   error(['Transformation ' num2str(trans) ' not defined.']);
042
043 end % switch
044
045 %
046 % log-odds
047 %
048
049 function y = logOdds(x)
050
051 y=log(x./(1-x));
052
053```

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