Home > wafo > wstats > dist2dpdf.m

# dist2dpdf

## PURPOSE

Joint 2D PDF computed as f(x1|X2=x2)*f(x2)

## SYNOPSIS

y = dist2dpdf(v1,h1,phat)

## DESCRIPTION

``` DIST2DPDF Joint 2D PDF computed as f(x1|X2=x2)*f(x2)

CALL:  f = dist2dpdf(x1,x2,phat)

f  = PDF evaluated at x1,x2
x1,x2  = evaluation points
phat = structure array containing
x    = cellarray of distribution parameters
dist = cellarray of strings defining the distributions of
X2 and X1 given X2, respectively. Options are:
'tgumbel', 'gumbel', 'lognormal','rayleigh','weibull',
and 'gamma'.

DIST2DPDF evaluates f{x1|X2=x2}*f{x2}.
The parameter(s) of the unconditional distribution of X2,
f{x2}, must be in in phat.x{2}. The parameters of the conditional
distribution of X1 given X2 must be in phat.x{1}. The first column
in phat.x{1} contains the X2 values the parameters in column 2 and 3 are
conditioned on.

The size of f is the common size of X1 and X2.

Example: 2D Rayleigh, ie, f(x1)*f(x2)
x1=linspace(0,10)';
phat0.x={[x1,2*ones(size(x1))] 2 };
phat0.dist={'rayl','rayl'};
dist2dpdf(2,1,phat0)

## CROSS-REFERENCE INFORMATION

This function calls:
 dist2dsmfun Smooths the conditional DIST2D distribution parameters. wgampdf Gamma probability density function wggampdf Generalized Gamma probability density function wgumbpdf Gumbel probability density function. wlognpdf Lognormal probability density function wraylpdf Rayleigh probability density function wtraylpdf Truncated Rayleigh probability density function wtweibpdf Truncated Weibull probability density function wweibpdf Weibull probability density function error Display message and abort function. lower Convert string to lowercase. strcmp Compare strings.
This function is called by:
 dist2dpdf2 Joint 2D PDF computed as f(x1|X2=x2)*f(x2)

## SOURCE CODE

```001 function y = dist2dpdf(v1,h1,phat)
002 %DIST2DPDF Joint 2D PDF computed as f(x1|X2=x2)*f(x2)
003 %
004 % CALL:  f = dist2dpdf(x1,x2,phat)
005 %
006 %      f  = PDF evaluated at x1,x2
007 %  x1,x2  = evaluation points
008 %    phat = structure array containing
009 %           x    = cellarray of distribution parameters
010 %           dist = cellarray of strings defining the distributions of
011 %                  X2 and X1 given X2, respectively. Options are:
012 %                  'tgumbel', 'gumbel', 'lognormal','rayleigh','weibull',
013 %                  and 'gamma'.
014 %
015 % DIST2DPDF evaluates f{x1|X2=x2}*f{x2}.
016 %  The parameter(s) of the unconditional distribution of X2,
017 %  f{x2}, must be in in phat.x{2}. The parameters of the conditional
018 %  distribution of X1 given X2 must be in phat.x{1}. The first column
019 %  in phat.x{1} contains the X2 values the parameters in column 2 and 3 are
020 %  conditioned on.
021 %
022 % The size of f is the common size of X1 and X2.
023 %
024 % Example: 2D Rayleigh, ie, f(x1)*f(x2)
025 %   x1=linspace(0,10)';
026 %   phat0.x={[x1,2*ones(size(x1))] 2 };
027 %   phat0.dist={'rayl','rayl'};
028 %   dist2dpdf(2,1,phat0)
029 %
031
032 %tested on: matlab 5.2
033 % history:
034 % revised pab 19.01.2001
035 % revised pab 03.12.2000
036 % added truncated weibull and truncated raleigh
037 % revised pab 12.11.2000
038 %  - added ggampdf option
039 % revised pab 08.02.2000
040 %   fixed a bug CV -> Cv
041 %  Per A. Brodtkorb 28.10.98
042
043 error(nargchk(3,3,nargin))
044
045 dist=phat.dist;
046
047 V=v1;
048 H=h1;
049
050 y = zeros(max([size(V) ;size(H)]));
051
052 if strcmp('gu', lower(dist{1}(1:2))),
053   if strcmp('gu', lower(dist{2}(1:2))),
054     k=find(H>-inf);
055   else
056     k=find(H>0);
057   end
058 elseif strcmp('gu', lower(dist{2}(1:2))),
059   k = find(V > 0 );
060 else
061   k = find(V > 0 & H>0);
062 end
063
064 PH=phat.x{2};
065
066
067 if any(k),
068     switch lower(dist{2}(1:2))
069       case 'tr' ,  pdf1=wtraylpdf(H(k),PH(1),PH(2));
070       case 'ra' ,  pdf1=wraylpdf(H(k),PH);
071       case 'we' ,  pdf1=wweibpdf(H(k),PH(1),PH(2));
072       case 'tw' ,  pdf1=wtweibpdf(H(k),PH(1),PH(2),PH(3));
073       case 'gu' ,  pdf1=wgumbpdf(H(k),PH(1),PH(2),0);
074       case 'tg' ,  pdf1=wgumbpdf(H(k),PH(1),PH(2),1);
075       case 'ga' ,  pdf1=wgampdf(H(k),PH(1),PH(2));
076       case 'gg' ,  pdf1=wggampdf(H(k),PH(1),PH(2),PH(3));
077       case 'lo' ,  pdf1=wlognpdf(H(k),PH(1),PH(2));
078       otherwise, error('unknown distribution')
079     end
080     [Av , Bv, Cv]=dist2dsmfun(phat,H(k)); %parameters of V given H
081    switch lower(dist{1}(1:2))
082      case 'tr', y(k) =  pdf1.*wtraylpdf(V(k),Av,Bv);
083      case 'ra', y(k) =  pdf1.*wraylpdf(V(k)-Cv,Av);
084      case 'gu', y(k) =  pdf1.*wgumbpdf(V(k)-Cv,Av,Bv,0);
085      case 'tg', y(k) =  pdf1.*wgumbpdf(V(k)-Cv,Av,Bv,1);
086      case 'lo', y(k) =  pdf1.*wlognpdf(V(k)-Cv,Av,Bv);
087      case 'ga', y(k) =  pdf1.*wgampdf(V(k)-Cv,Av,Bv);
088      case 'gg', y(k) =  pdf1.*wggampdf(V(k),Av,Bv,Cv);
089      case 'we', y(k) =  pdf1.*wweibpdf(V(k)-Cv,Av,Bv);
090      case 'tw', y(k) =  pdf1.*wtweibpdf(V(k),Av,Bv,Cv);
091      otherwise, error('Unknown distribution')
092    end
093 end
094
095 %y(find(isnan(y)|isinf(y)))=0;
096
097```

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