home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / stat / base / ppplot.m < prev    next >
Text File  |  1999-04-29  |  2KB  |  68 lines

  1. ## Copyright (C) 1995, 1996, 1997  Kurt Hornik
  2. ## 
  3. ## This program is free software; you can redistribute it and/or modify
  4. ## it under the terms of the GNU General Public License as published by
  5. ## the Free Software Foundation; either version 2, or (at your option)
  6. ## any later version.
  7. ## 
  8. ## This program is distributed in the hope that it will be useful, but
  9. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11. ## General Public License for more details. 
  12. ## 
  13. ## You should have received a copy of the GNU General Public License
  14. ## along with this file.  If not, write to the Free Software Foundation,
  15. ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16.  
  17. ## usage:  [p, y] = ppplot (x [, dist [, params]])
  18. ##
  19. ## Performs a PP-plot (probability plot).
  20. ##
  21. ## If F is the CDF of the distribution `dist' with parameters `params'
  22. ## and x a sample vector of length n, the PP-plot graphs ordinate y(i) =
  23. ## F (i-th largest element of x) versus abscissa p(i) = (i - 0.5)/n. If
  24. ## the sample comes from F, the pairs will approximately follow a
  25. ## straight line.
  26. ##
  27. ## The default for `dist' is the standard normal distribution.  The
  28. ## optional argument `params' contains a list of parameters of
  29. ## `dist'. E.g., for a probability plot of the uniform distribution on
  30. ## [2,4] ans x, use `ppplot (x, "uniform", 2, 4)'.
  31. ##
  32. ## If no output arguments are given, the data are plotted directly.
  33.  
  34. ## Author:  KH <Kurt.Hornik@ci.tuwien.ac.at>
  35. ## Description:  Perform a PP-plot (probability plot)
  36.  
  37. function [p, y] = ppplot (x, dist, ...)
  38.   
  39.   if (nargin < 1)
  40.     usage ("ppplot (x [, dist [, params]])");
  41.   endif
  42.   
  43.   if !is_vec (x)
  44.     error ("ppplot:  x must be a vector.");
  45.   endif
  46.  
  47.   s = sort (x);
  48.   n = length (x);
  49.   p = ((1 : n)' - 0.5) / n;
  50.   if (nargin == 1)
  51.     F = "stdnorm_cdf";
  52.   else
  53.     F = sprintf ("%s_cdf", dist);
  54.   endif;
  55.   if (nargin <= 2)
  56.     y = feval (F, s);
  57.   else
  58.     y = feval (F, s, all_va_args);
  59.   endif
  60.   
  61.   if (nargout == 0)
  62.     axis ([0, 1, 0, 1]);
  63.     set nokey;
  64.     plot (p, y);
  65.   endif
  66.  
  67. endfunction
  68.