TR_X2P Transforms a vector X to a transition matrix P. CALL: P = tr_x2p(X,trans) P = transition matrix. [rxr] X = Vector of length n=r*(r-1). [nx1] trans = 0: No transformation. (default) 1: inverse log-odds-transformation. x = 1/(exp(-y)+1) See also tr_p2x
Estimate SMCTP model from an observed rainflow matrix. | |
Auxiliary function used by ESTSMCTP |
001 function P = tr_x2p(X,trans) 002 % TR_X2P Transforms a vector X to a transition matrix P. 003 % 004 % CALL: P = tr_x2p(X,trans) 005 % 006 % P = transition matrix. [rxr] 007 % 008 % X = Vector of length n=r*(r-1). [nx1] 009 % trans = 0: No transformation. (default) 010 % 1: inverse log-odds-transformation. 011 % x = 1/(exp(-y)+1) 012 % 013 % See also tr_p2x 014 015 if nargin<2, trans=[]; end 016 if isempty(trans), trans=0; end 017 018 r=(1+sqrt(1+4*length(X)))/2; 019 020 switch trans 021 022 case 0 % No transformation 023 024 case 1 % inverse-log-odds-transformation 025 026 X = invlogOdds(X); 027 028 otherwise 029 030 error(['Transformation ' num2str(trans) ' not defined.']); 031 032 end % switch 033 034 E= eye(r); 035 EE = E(:); 036 IE = find(EE==0); 037 Y = zeros(r*r,1); 038 Y(IE) = X; 039 P = reshape(Y,r,r)'; 040 for i = 1:r 041 P(i,i) = 1-sum(P(i,:)); 042 end 043 044 % 045 % inverse of log-odds 046 % 047 048 function x=invlogOdds(y) 049 050 x=1./(exp(-y)+1); 051 052
Comments or corrections to the WAFO group