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)) See also trX2P.
Estimate SMCTP model from an observed rainflow matrix. |
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 % 017 % See also trX2P. 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
Comments or corrections to the WAFO group