Home > wafo > wstats > weib2drnd.m

weib2drnd

PURPOSE ^

Random numbers from the 2D Weibull distribution.

SYNOPSIS ^

[r1, r2, ind]= weib2drnd(parm,m,n,tol)

DESCRIPTION ^

 WEIB2DRND Random numbers from the 2D Weibull distribution.
 
  CALL:  [R1 R2] = weib2drnd(param,M,N,tol);
 
   R1,R2 = two matrices of simulated data of size M x N
   param = [A1,B1,A2,B2,C12] parameters of the distribution
   m, n  = size of R1, R2 (default m=1,n=1)
   tol   = relative tolerance (default 1e-3)
 
   The samples are generated by inversion.
 
  Example:
    [R1 R2]=weib2drnd([2,2,1,3,.8],2000,1);
    wweibplot(R1);
    plot(R1,R2,'.')
 
  See also  weib2dcinv, wweibrnd, rand

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [r1, r2, ind]= weib2drnd(parm,m,n,tol)
002 %WEIB2DRND Random numbers from the 2D Weibull distribution.
003 %
004 % CALL:  [R1 R2] = weib2drnd(param,M,N,tol);
005 %
006 %  R1,R2 = two matrices of simulated data of size M x N
007 %  param = [A1,B1,A2,B2,C12] parameters of the distribution
008 %  m, n  = size of R1, R2 (default m=1,n=1)
009 %  tol   = relative tolerance (default 1e-3)
010 %
011 %  The samples are generated by inversion.
012 %
013 % Example:
014 %   [R1 R2]=weib2drnd([2,2,1,3,.8],2000,1);
015 %   wweibplot(R1);
016 %   plot(R1,R2,'.')
017 %
018 % See also  weib2dcinv, wweibrnd, rand
019 
020 %tested on matlab 5.1
021 %history:
022 % by Per A. Brodtkorb 19.11.98
023 
024 error(nargchk(1,4,nargin))
025 if prod(size(parm))~=5,  error('param must have 5 entries.'); end
026 if nargin<2|isempty(m),m=1;end
027 if nargin<3|isempty(n),n=1;end
028 if nargin<4|isempty(tol),tol=1e-3;end
029 
030 % Return NaN if  ai or b is not positive  
031 if any(any(parm(1:4) <= 0))| abs(parm(5))>=1;;
032   tmp = NaN;
033   r2 = tmp(ones(m,n));  
034   r1=r2;
035   disp('Warning: parameters are not valid, NaNs returned')
036   return
037 end
038 
039 r1 = zeros(m,n);
040 r2= r1;
041 
042 r1=wweibrnd(parm(1),parm(2),m,n);
043 % perform a direct inversion by newton
044 P=rand(m,n);
045 [r2 ind]=weib2dcinv(r1 ,P,parm,tol); % Inverse of the 2D weibull cdf given X1 . slow
046 
047 
048 
049 
050

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