Home > wafo > wstats > dist2dparamplot.m

dist2dparamplot

PURPOSE ^

Plot parameters of the conditional distribution

SYNOPSIS ^

dist2dparamplot(PV1,sPV1,plotflag),

DESCRIPTION ^

 DIST2DPARAMPLOT Plot parameters of the conditional distribution
 
  CALL:  dist2dparamplot(PV,sPV,plotflag)
 
        PV  = empirical parameters (structure array)
        sPV = smoothed parameters  (structure array)
   plotflag = 0 no plotting
              1 Only parameter A is plotted
              2 Only parameter B is plotted
              3 Only parameter C is plotted
              4 all  parameters are plotted in the same figure (default)
 
  Example: 
    R = wraylrnd(2,1000,2); x1 = linspace(0,10)';
    phat = dist2dfit(R(:,1),R(:,2),{'rayl','rayl'}); 
    sphat = dist2dsmfun2(phat,x1,0); % smooth the parameters
    dist2dparamplot(phat,sphat); 
 
  See also  dist2dfit, dist2dsmfun2

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function dist2dparamplotdist2dparamplot(PV1,sPV1,plotflag),
002 %DIST2DPARAMPLOT Plot parameters of the conditional distribution
003 %
004 % CALL:  dist2dparamplot(PV,sPV,plotflag)
005 %
006 %       PV  = empirical parameters (structure array)
007 %       sPV = smoothed parameters  (structure array)
008 %  plotflag = 0 no plotting
009 %             1 Only parameter A is plotted
010 %             2 Only parameter B is plotted
011 %             3 Only parameter C is plotted
012 %             4 all  parameters are plotted in the same figure (default)
013 %
014 % Example: 
015 %   R = wraylrnd(2,1000,2); x1 = linspace(0,10)';
016 %   phat = dist2dfit(R(:,1),R(:,2),{'rayl','rayl'}); 
017 %   sphat = dist2dsmfun2(phat,x1,0); % smooth the parameters
018 %   dist2dparamplot(phat,sphat); 
019 %
020 % See also  dist2dfit, dist2dsmfun2
021 
022 % history
023 % revised pab 19.01.2001
024 % - phat.CI may now be empty
025 % - better scaling of plots
026 % revised pab 12.11.2000
027 % - added  the possibility that phat is an array of structs
028 % revised pab 06.02.2000
029 % - added plotflag
030 % - simplified plotting
031 % by pab 
032 
033 
034 
035 
036 if nargin<3|isempty(plotflag)
037   plotflag=4;
038 elseif plotflag<1
039   return
040 end
041 Npv = prod(size(PV1));
042 ih=ishold;
043 if isstruct(PV1) & Npv>1
044   cfig=gcf;
045   for ix=1:Npv,
046     if ih
047       newplot
048     else
049       figure(cfig-1+ix)
050     end
051     if nargin<2|isempty(sPV1)
052       dist2dparamplot(PV1(ix),[],plotflag)
053     else
054       dist2dparamplot(PV1(ix),sPV1(ix),plotflag)
055     end
056   end
057   return
058 end
059 
060 
061 if nargin<2|isempty(sPV1)
062   sPV=[];
063 elseif isstruct(sPV1)
064   sPV=sPV1.x{1};
065 else
066   sPV=sPV1;
067 end
068 
069 dist=lower(PV1.dist{1});
070 if isfield(PV1,'CI') & ~isempty(PV1.CI);
071   pvCI=PV1.CI{1};
072   indCI=find(~isnan(pvCI(:,1)));
073   isCI=any( pvCI(indCI,1:2:end));
074   isCI=[isCI zeros(1,3-length(isCI))];
075 else
076   isCI=zeros(1,3);
077 end
078 txtCI=' and 95 % CI';
079 
080 pv=PV1.x{1};
081 np=size(pv,2)-1;
082 
083 ind=find(~isnan(pv(:,1)));
084   
085 Arange=[0 inf 0 inf];Brange=[0 inf -inf inf];Crange=[0 inf -inf inf];
086 switch lower(dist(1:2)),
087   case {'tg','gu'},  txt='Gumbel';  
088   case 'lo', txt='Lognormal';Arange=[0 inf -inf  inf];Brange=[0 inf 0 inf];
089   case 'ga', txt='Gamma';Brange=[0 inf 0  inf];
090   case 'gg', txt='Generalized Gamma';Brange=Arange;Crange = Arange; 
091   case 'we', txt='Weibull';Brange=[0 inf 0 inf];
092   otherwise, txt=[];
093 end
094 Arange(4)= min(max(pv(ind,2)),20);
095 if np>1, Brange(4)=min(max(pv(ind,3)),20);
096  if np>2,  Crange(4)=min(max(pv(ind,4)),5);end
097 end
098 
099      
100  
101 paramtxt='ABC';
102 if strcmpi(dist(1:2),'ra'),  % rayleigh distribution
103   paramtxt(2)=[]; % No shape parameter
104   Prange={Arange, Crange};
105 else
106   Prange={Arange, Brange, Crange};
107 end
108 if plotflag>np, 
109   nplots=1:np;
110 else
111   nplots=plotflag;np=1;
112 end
113 
114 for ix=nplots,
115  
116   subplot(np,1,ix-nplots(1)+1)
117   if ih , hold on, end
118   plot(pv(ind,1),pv(ind,ix+1),'bo'), hold on
119   if isCI(ix)
120     plot(pv(indCI,1),pvCI(indCI,2*ix-1:2*ix),'r--')
121     title([txt ' parameter ' paramtxt(ix) txtCI])
122   else
123     title([txt ' parameter ' paramtxt(ix)])
124   end
125   
126   if ~isempty(sPV),
127     plot(sPV(:,1),sPV(:,ix+1),'b-')
128   end
129   if ~ih, hold off, end
130   axis(Prange{ix})
131   xlabel('x2')
132   ylabel([paramtxt(ix) '(x2)'])
133 end
134 return
135

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