Home > wafo > wstats > dist2drnd.m

dist2drnd

PURPOSE ^

Random points from a bivariate DIST2D distribution

SYNOPSIS ^

[V,H] = dist2drnd(N,phat,csm,lin)

DESCRIPTION ^

 DIST2DRND  Random points from a bivariate DIST2D distribution 
   
   CALL:  [x1,x2] = dist2drnd(N,phat,[csma,csmb,csmc],[lina,linb,linc]);
 
     X1,X2   = N random points in R^2.
     N       = number of points generated
     phat    = parameter structure array (see dist2dfit)
     csma..c =  vector of internal smoothing parameters (default [1 1 1])
                0 -> LS-straight line
                1 -> cubic spline interpolant
    lina..c  = vector defining the extrapolation of parameter A,B and C, respectively 
               0 No linear extrapolation outside the range of data
               1 Linear extrapolation outside the range of data (default)
 
  Example: Random points from a 2D Rayleigh distribution
    x1=linspace(0,10)';
    phat.x={[x1,exp(-0.1*x1)] 2 };
    phat.dist={'rayl','rayl'};
    [y1,y2] = dist2drnd(1000,phat);
    f = dist2dpdf2(x1,x1,phat);
    pdfplot(f), hold on
    plot(y1,y2,'.'), hold off
    
 
  See also  dist2dfit , dist2dpdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [V,H] = dist2drnd(N,phat,csm,lin)
002 %DIST2DRND  Random points from a bivariate DIST2D distribution 
003 %  
004 %  CALL:  [x1,x2] = dist2drnd(N,phat,[csma,csmb,csmc],[lina,linb,linc]);
005 %
006 %    X1,X2   = N random points in R^2.
007 %    N       = number of points generated
008 %    phat    = parameter structure array (see dist2dfit)
009 %    csma..c =  vector of internal smoothing parameters (default [1 1 1])
010 %               0 -> LS-straight line
011 %               1 -> cubic spline interpolant
012 %   lina..c  = vector defining the extrapolation of parameter A,B and C, respectively 
013 %              0 No linear extrapolation outside the range of data
014 %              1 Linear extrapolation outside the range of data (default)
015 %
016 % Example: Random points from a 2D Rayleigh distribution
017 %   x1=linspace(0,10)';
018 %   phat.x={[x1,exp(-0.1*x1)] 2 };
019 %   phat.dist={'rayl','rayl'};
020 %   [y1,y2] = dist2drnd(1000,phat);
021 %   f = dist2dpdf2(x1,x1,phat);
022 %   pdfplot(f), hold on
023 %   plot(y1,y2,'.'), hold off
024 %   
025 %
026 % See also  dist2dfit , dist2dpdf
027 
028 % tested on: matlab 5.2
029 % history:
030 % by Per A. Brodtkorb 28.10.98
031 
032 error(nargchk(2,4,nargin))
033 
034 if (nargin< 3)|isempty(csm), 
035   csm=[];
036 end
037 if (nargin< 4)|isempty(lin), 
038   lin=[];
039 end
040 UDIST=phat.dist{2};
041 CDIST=phat.dist{1};
042 
043 PH=phat.x{2};
044 
045   
046 % H is distributed
047 switch UDIST(1:2),
048   case 'ra', H=wraylrnd(PH(ones(N,1),:));
049   case 'we', H=wweibrnd(PH(ones(N,1),1) , PH(ones(N,1),2));
050   case 'tg', H=wgumbrnd(PH(ones(N,1),1) , PH(ones(N,1),2),1);
051   case 'gu', H=wgumbrnd(PH(ones(N,1),1) , PH(ones(N,1),2),0);
052   case 'lo', H=wlognrnd(PH(ones(N,1),1) , PH(ones(N,1),2));
053   case 'ga', H=wgamrnd(PH(ones(N,1),1) , PH(ones(N,1),2));    
054 end
055  
056 
057 [Av , Bv, Cv]=dist2dsmfun(phat,H,csm,lin); %parameters of V given H 
058 
059 % V conditioned on H  is distributed 
060 switch CDIST(1:2)
061   case 'ra', V = wraylrnd(Av)+Cv;
062   case 'gu', V = wgumbrnd(Av,Bv,0)+Cv;% tGumbel
063   case 'tg', V = wgumbrnd(Av,Bv,1)+Cv;% truncated  Gumbel
064   case 'lo', V = wlognrnd(Av,Bv)+Cv;
065   case 'ga', V = wgamrnd(Av,Bv)+Cv;    
066   case 'we', V = wweibrnd(Av,Bv)+Cv;
067   otherwise, error('Unknown distribution') 
068 end
069 
070 
071

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