From: <car...@us...> - 2011-10-06 00:53:48
|
Revision: 8686 http://octave.svn.sourceforge.net/octave/?rev=8686&view=rev Author: carandraug Date: 2011-10-06 00:53:41 +0000 (Thu, 06 Oct 2011) Log Message: ----------- data-smoothing: * small fixes on help text * use of a short-circuit operator in rgdtsmcore * some code prettifier * removed copy of var in rgdtsmcorewrap Modified Paths: -------------- trunk/octave-forge/main/data-smoothing/DESCRIPTION trunk/octave-forge/main/data-smoothing/inst/ddmat.m trunk/octave-forge/main/data-smoothing/inst/regdatasmooth.m trunk/octave-forge/main/data-smoothing/inst/rgdtsmcore.m trunk/octave-forge/main/data-smoothing/inst/rgdtsmcorewrap.m Modified: trunk/octave-forge/main/data-smoothing/DESCRIPTION =================================================================== --- trunk/octave-forge/main/data-smoothing/DESCRIPTION 2011-10-06 00:15:18 UTC (rev 8685) +++ trunk/octave-forge/main/data-smoothing/DESCRIPTION 2011-10-06 00:53:41 UTC (rev 8686) @@ -1,6 +1,6 @@ Name: data-smoothing -Version: 1.2.1 -Date: 2009-11-16 +Version: 1.2.2 +Date: 2011-10-06 Author: Jonathan Stickel <jon...@nr...> Maintainer: Jonathan Stickel <jon...@nr...> Title: Data smoothing Modified: trunk/octave-forge/main/data-smoothing/inst/ddmat.m =================================================================== --- trunk/octave-forge/main/data-smoothing/inst/ddmat.m 2011-10-06 00:15:18 UTC (rev 8685) +++ trunk/octave-forge/main/data-smoothing/inst/ddmat.m 2011-10-06 00:53:41 UTC (rev 8686) @@ -1,4 +1,5 @@ ## Copyright (C) 2003 Paul Eilers +## ## This program 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 of the License, or @@ -13,29 +14,28 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -##@deftypefn {Function File} {@var{D} =} ddmat (@var{x}, @var{o}) +## @deftypefn {Function File} {@var{D} =} ddmat (@var{x}, @var{o}) ## Compute divided differencing matrix of order @var{o} ## ## @itemize @w ## @item Input ## @itemize @w -## @item @var{x}: vector of sampling positions -## @item @var{o}: order of diffferences +## @item @var{x}: vector of sampling positions +## @item @var{o}: order of diffferences ## @end itemize ## @item Output ## @itemize @w -## @item @var{D}: the matrix; @var{D} * Y gives divided differences of order @var{o} +## @item @var{D}: the matrix; @var{D} * Y gives divided differences of order @var{o} ## @end itemize ## @end itemize ## -##References: Anal. Chem. (2003) 75, 3631. +## References: Anal. Chem. (2003) 75, 3631. ## ## @end deftypefn ## corrected the recursion multiplier; JJS 2/25/08 ## added error check that x is a column vector; JJS 4/13/09 - function D = ddmat(x, d) if ( size(x,2) != 1 ) error("x should be a column vector") Modified: trunk/octave-forge/main/data-smoothing/inst/regdatasmooth.m =================================================================== --- trunk/octave-forge/main/data-smoothing/inst/regdatasmooth.m 2011-10-06 00:15:18 UTC (rev 8685) +++ trunk/octave-forge/main/data-smoothing/inst/regdatasmooth.m 2011-10-06 00:53:41 UTC (rev 8686) @@ -1,4 +1,5 @@ ## Copyright (C) 2008 Jonathan Stickel <jon...@nr...> +## ## This program 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 of the License, or @@ -57,7 +58,7 @@ ## Please run the demos for example usage. ## ## References: Anal. Chem. (2003) 75, 3631; AIChE J. (2006) 52, 325 -## @seealso{rgdtsmcore} +## @seealso{rgdtsmcorewrap, rgdtsmcore} ## @end deftypefn function [yhat, lambda] = regdatasmooth (x, y, varargin) @@ -100,13 +101,13 @@ ## add warning if more than one gcv, lambda, or stdev options provided? - if (length(x)!=length(y)) + if ( length(x) != length(y) ) error("x and y must be equal length vectors") endif - if ( size(x,1)==1 ) + if ( size(x,1) == 1 ) x = x'; endif - if ( size(y,1)==1 ) + if ( size(y,1) == 1 ) y = y'; endif @@ -128,7 +129,7 @@ ##[log10lambda,fout,exitflag] = fminunc_compat (fhandle, guess, opt); ## derivative-free optimization; should use "fminsearch" for Matlab ## compatibility, but fminsearch needs updates to be more compatible itself - [log10lambda,fout,niter] = nelder_mead_min (fhandle, guess, "ftol",1e-6, "maxev",maxiter); + [log10lambda, fout, niter] = nelder_mead_min (fhandle, guess, "ftol", 1e-6, "maxev", maxiter); if (niter > maxiter) exitflag = 0; else Modified: trunk/octave-forge/main/data-smoothing/inst/rgdtsmcore.m =================================================================== --- trunk/octave-forge/main/data-smoothing/inst/rgdtsmcore.m 2011-10-06 00:15:18 UTC (rev 8685) +++ trunk/octave-forge/main/data-smoothing/inst/rgdtsmcore.m 2011-10-06 00:53:41 UTC (rev 8686) @@ -1,4 +1,5 @@ ## Copyright (C) 2008 Jonathan Stickel <jon...@nr...> +## ## This program 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 of the License, or @@ -26,22 +27,23 @@ ## Note: the options have changed! ## Currently supported input options are (multiple options are allowed): ## -##@table @code -##@item "xhat", @var{vector} -## A vector of x-values to use for the smooth curve; must be -## monotonically increasing and must at least span the data -##@item "weights", @var{vector} -## A vector of weighting values for fitting each point in the data. -##@item "relative" -## use relative differences for the goodnes of fit term. Conflicts -## with the "weights" option. -##@item "midpointrule" -## use the midpoint rule for the integration terms rather than a direct -## sum; this option conflicts with the option "xhat" -##@end table +## @table @code +## @item "xhat", @var{vector} +## A vector of x-values to use for the smooth curve; must be +## monotonically increasing and must at least span the data +## @item "weights", @var{vector} +## A vector of weighting values for fitting each point in the data. +## @item "relative" +## use relative differences for the goodnes of fit term. Conflicts +## with the "weights" option. +## @item "midpointrule" +## use the midpoint rule for the integration terms rather than a direct +## sum; this option conflicts with the option "xhat" +## @end table ## ## References: Anal. Chem. (2003) 75, 3631; AIChE J. (2006) 52, 325 -##@end deftypefn +## @seealso{regdatasmooth} +## @end deftypefn function [yhat, v] = rgdtsmcore (x, y, d, lambda, varargin) @@ -95,7 +97,7 @@ endif endif ## test that xhat spans x - if ( min(x) < min(xhat) | max(xhat) < max(x) ) + if ( min(x) < min(xhat) || max(xhat) < max(x) ) error("xhat must at least span the data") endif Modified: trunk/octave-forge/main/data-smoothing/inst/rgdtsmcorewrap.m =================================================================== --- trunk/octave-forge/main/data-smoothing/inst/rgdtsmcorewrap.m 2011-10-06 00:15:18 UTC (rev 8685) +++ trunk/octave-forge/main/data-smoothing/inst/rgdtsmcorewrap.m 2011-10-06 00:53:41 UTC (rev 8686) @@ -1,4 +1,5 @@ ## Copyright (C) 2008 Jonathan Stickel <jon...@nr...> +## ## This program 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 of the License, or @@ -13,12 +14,14 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{cve}|@var{stdevdif} =} rgdtsmcorewrap (@var{log10lambda}, @var{x}, @var{y}, @var{d}, @var{mincell}, @var{options}) +## @deftypefn {Function File} {@var{cve} =} rgdtsmcorewrap (@var{log10lambda}, @var{x}, @var{y}, @var{d}, @var{mincell}, @var{options}) +## @deftypefnx {Function File} {@var{stdevdif} =} rgdtsmcorewrap (@var{log10lambda}, @var{x}, @var{y}, @var{d}, @var{mincell}, @var{options}) ## ## Wrapper function for rgdtsmcore in order to minimize over ## @var{lambda} w.r.t. cross-validation error OR the squared difference ## between the standard deviation of (@var{y}-@var{yhat}) and the given ## standard deviation. This function is called from regdatasmooth. +## @seealso{regdatasmooth} ## @end deftypefn @@ -26,9 +29,9 @@ lambda = 10^(log10lambda); - if ( length(mincell)==2 ) # using stdev to find optimal lambda + if ( length(mincell) == 2 ) # using stdev to find optimal lambda stdev = mincell{2}; - yhat = rgdtsmcore (x, y, d, lambda, varargin{:}); + yhat = rgdtsmcore (x, y, d, lambda, varargin{:}); xhatprov = 0; relative = 0; @@ -59,8 +62,7 @@ out = (stdevd - stdev)^2; else # use gcv to find optimal lambda - [yhat, cve] = rgdtsmcore (x, y, d, lambda, varargin{:}); - out = cve; + [yhat, out] = rgdtsmcore (x, y, d, lambda, varargin{:}); endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |