Home > wafo > wstats > distplot.m

# distplot

## PURPOSE

Displays a 1D distribution probability plot.

## SYNOPSIS

h = wdistplot(x,dist)

## DESCRIPTION

``` DISTPLOT Displays a 1D distribution probability plot.

CALL:  H = distplot(R,dist);

H    = handle to the plotted lines.
R    = data
dist = string containing the name of the PDF.

The purpose of a distribution probability plot is to graphically assess
whether the data in X could come from a given distribution. If so
the plot will be linear. Other distribution types
will introduce curvature in the plot.

This works on any PDF having the following calling syntax:

phat = pdffit(R);
x    = pdfinv(p,phat(1),phat(2),...,phat(n));

where R contain the data and phat(1),phat(2)... are
the distribution parameters.

Example:
R = wgamrnd(1,2,100,1);
distplot(R,'wgampdf');```

## CROSS-REFERENCE INFORMATION

This function calls:
 figtext Places text in figure window. wqqplot Plot empirical quantile of X vs empirical quantile of Y axis Control axis scaling and appearance. error Display message and abort function. grid Grid lines. hold Hold current graph. num2cell Convert numeric array into cell array. num2str Convert number to string. (Fast version) plot Linear plot. set Set object properties. title Graph title. xlabel X-axis label. ylabel Y-axis label.
This function is called by:
 dist2dfit Parameter estimates for DIST2D data.

## SOURCE CODE

```001 function h = wdistplot(x,dist)
002 %DISTPLOT Displays a 1D distribution probability plot.
003 %
004 % CALL:  H = distplot(R,dist);
005 %
006 %   H    = handle to the plotted lines.
007 %   R    = data
008 %   dist = string containing the name of the PDF.
009 %
010 %   The purpose of a distribution probability plot is to graphically assess
011 %   whether the data in X could come from a given distribution. If so
012 %   the plot will be linear. Other distribution types
013 %   will introduce curvature in the plot.
014 %
015 %   This works on any PDF having the following calling syntax:
016 %
017 %    phat = pdffit(R);
018 %    x    = pdfinv(p,phat(1),phat(2),...,phat(n));
019 %
020 %   where R contain the data and phat(1),phat(2)... are
021 %   the distribution parameters.
022 %
023 % Example:
024 %   R = wgamrnd(1,2,100,1);
025 %   distplot(R,'wgampdf');
026 %
027
028 % Tested on: Matlab 5.3
029 % History:
030 %   Per A. Brodtkorb 12.11.2000
031
032 error(nargchk(2,2,nargin))
033
034 x=x(:);
035 n=length(x);
036
037 pdf=dist(1:end-3);
038
039
040 eprob = [0.5./n:1./n:(n - 0.5)./n];
041 phat  = feval( [ pdf 'fit'],x);% MLE of the distribution parameters
042 cphat = num2cell(phat,1);
043
044 y  = feval([ pdf 'inv'],eprob,cphat{:})';
045
046 p     = [0.001 0.02 0.05 0.10 0.25 0.5 0.75 0.90 0.95 0.98 0.99 0.997 0.999];
047 tick  = feval([ pdf 'inv'],p,cphat{:});
048
049 if nargout > 0
050    h = wqqplot(x,y);
051 else
052    wqqplot(x,y);
053 end
054
055
056 xlabel('Data');
057 ylabel([ pdf ' Quantiles']) %'Probability');
058 title( [ pdf ' Probability Plot']);
059
060 ax=axis;hold on
061 plot([ax(1) ax(2)],[tick; tick],'k:'); hold off
062 for l=1:length(p)
063   h1=figtext(1.01,tick(l),num2str(p(l)) ,'norm','data');
064   set(h1,'FontSize',10,'FontAngle','Italic')
065 end
066 %axis([0 inf 0 inf])
067 grid on;
068
069```

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