changeset 6356:8bb0d11c7a97

[project @ 2007-02-26 14:45:29 by dbateman]
author dbateman
date Mon, 26 Feb 2007 14:48:22 +0000
parents 7b124b265c34
children d93787dbedec
files scripts/ChangeLog scripts/pkg/pkg.m scripts/statistics/distributions/unidcdf.m scripts/statistics/distributions/unidinv.m scripts/statistics/distributions/unidpdf.m scripts/statistics/distributions/unidrnd.m
diffstat 6 files changed, 180 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sun Feb 25 16:25:52 2007 +0000
+++ b/scripts/ChangeLog	Mon Feb 26 14:48:22 2007 +0000
@@ -1,3 +1,8 @@
+2007-02-24  David Bateman  <dbateman@free.fr>
+
+	* pkg/pkg.m (configure_make): Ignore blank lines and trailing
+	'\n' in FILES file.
+
 2007-02-24  David Bateman  <dbateman@free.fr>
 
 	* statistics/distributions (SOURCES): Add nbincdf.m,
--- a/scripts/pkg/pkg.m	Sun Feb 25 16:25:52 2007 +0000
+++ b/scripts/pkg/pkg.m	Mon Feb 26 14:48:22 2007 +0000
@@ -666,11 +666,20 @@
             endif
             filenames = char(fread(fid))';
             fclose(fid);
+	    if (filenames(end) == "\n")
+	      filenames(end) = [];
+	    endif
             ## Copy the files
             fn = split_by(filenames, "\n");
+	    delete_idx =  [];
             for i = 1:length(fn)
-              fn{i} = fullfile(src, fn{i});
+	      if (!all(isspace(fn{i})))
+                fn{i} = fullfile(src, fn{i});
+	      else
+		delete_idx(end+1) = i;
+              endif
             endfor
+	    fn(delete_idx) = [];
             filenames = sprintf("%s ", fn{:});
         else
             m = dir(fullfile(src, "*.m"));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/statistics/distributions/unidcdf.m	Mon Feb 26 14:48:22 2007 +0000
@@ -0,0 +1,40 @@
+## Copyright (C) 2007  David Bateman
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, write to the Free
+## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} unidcdf (@var{x}, @var{v})
+## For each element of @var{x}, compute the cumulative distribution
+## function (CDF) at @var{x} of a univariate discrete distribution which
+## assumes the values in @var{v} with equal probability.
+## @end deftypefn
+
+function cdf = unidcdf (x, v)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  if (isscalar(v))
+    v = [1:v].';
+  else
+    v = v(:);
+  endif
+
+  cdf = discrete_cdf (x, v, ones(size(v)));
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/statistics/distributions/unidinv.m	Mon Feb 26 14:48:22 2007 +0000
@@ -0,0 +1,40 @@
+## Copyright (C) 2007  David Bateman
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, write to the Free
+## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} unidinv (@var{x}, @var{v})
+## For each component of @var{x}, compute the quantile (the inverse of
+## the CDF) at @var{x} of the univariate distribution which assumes the
+## values in @var{v} with equal probability
+## @end deftypefn
+
+function inv = unidinv (x, v)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  if (isscalar(v))
+    v = [1:v].';
+  else
+    v = v(:);
+  endif
+
+  inv = discrete_inv (x, v, ones(size(v)));
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/statistics/distributions/unidpdf.m	Mon Feb 26 14:48:22 2007 +0000
@@ -0,0 +1,40 @@
+## Copyright (C) 2007  David Bateman
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, write to the Free
+## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} unidpdf (@var{x}, @var{v})
+## For each element of @var{x}, compute the probability density function
+## (pDF) at @var{x} of a univariate discrete distribution which assumes
+## the values in @var{v} with equal probability.
+## @end deftypefn
+
+function pdf = unidpdf (x, v)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  if (isscalar(v))
+    v = [1:v].';
+  else
+    v = v(:);
+  endif
+
+  pdf = discrete_pdf (x, v, ones(size(v)));
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/statistics/distributions/unidrnd.m	Mon Feb 26 14:48:22 2007 +0000
@@ -0,0 +1,45 @@
+## Copyright (C) 2007  David Bateman
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, write to the Free
+## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} unidrnd (@var{v}, @var{r}, @var{c})
+## @deftypefnx {Function File} {} unidrnd (@var{v}, @var{sz})
+## Generate a row vector containing a random sample of values from
+## the univariate distribution which assumes the values in @var{v} with
+## eqal probability. If @var{v} is a scalar, it is promoted to @code{1:@var{v}}.
+##
+## If @var{r} and @var{c} are given create a matrix with @var{r} rows and
+## @var{c} columns. Or if @var{sz} is a vector, create a matrix of size
+## @var{sz}.
+## @end deftypefn
+
+function rnd = unidrnd (v, varargin)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  if (isscalar(v))
+    v = [1:v].';
+  else
+    v = v(:);
+  endif
+
+  rnd = discrete_rnd (v, ones(size(v)), varargin{:});
+endfunction