Mercurial > hg > octave-terminal
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 +++ b/scripts/ChangeLog @@ -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 +++ b/scripts/pkg/pkg.m @@ -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"));
new file mode 100644 --- /dev/null +++ b/scripts/statistics/distributions/unidcdf.m @@ -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
new file mode 100644 --- /dev/null +++ b/scripts/statistics/distributions/unidinv.m @@ -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
new file mode 100644 --- /dev/null +++ b/scripts/statistics/distributions/unidpdf.m @@ -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
new file mode 100644 --- /dev/null +++ b/scripts/statistics/distributions/unidrnd.m @@ -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