Mercurial > forge
comparison main/optim/inst/polyconf.m @ 9930:d30cfca46e8a octave-forge
optim: upgrade license to GPLv3+ and mention on DESCRIPTION the other package licenses
author | carandraug |
---|---|
date | Fri, 30 Mar 2012 15:14:48 +0000 |
parents | ff480e262776 |
children |
comparison
equal
deleted
inserted
replaced
9929:df50d0ae107f | 9930:d30cfca46e8a |
---|---|
1 ## Author: Paul Kienzle <pkienzle@gmail.com> | |
2 ## This program is granted to the public domain. | |
3 | |
1 ## [y,dy] = polyconf(p,x,s) | 4 ## [y,dy] = polyconf(p,x,s) |
2 ## | 5 ## |
3 ## Produce prediction intervals for the fitted y. The vector p | 6 ## Produce prediction intervals for the fitted y. The vector p |
4 ## and structure s are returned from polyfit or wpolyfit. The | 7 ## and structure s are returned from polyfit or wpolyfit. The |
5 ## x values are where you want to compute the prediction interval. | 8 ## x values are where you want to compute the prediction interval. |
29 ## xf = linspace(x(1),x(end),150); | 32 ## xf = linspace(x(1),x(end),150); |
30 ## [yf,dyf] = polyconf(p,xf,s,'ci'); | 33 ## [yf,dyf] = polyconf(p,xf,s,'ci'); |
31 ## plot(xf,yf,'g-;fit;',xf,yf+dyf,'g.;;',xf,yf-dyf,'g.;;',x,y,'xr;data;'); | 34 ## plot(xf,yf,'g-;fit;',xf,yf+dyf,'g.;;',xf,yf-dyf,'g.;;',x,y,'xr;data;'); |
32 ## plot(x,y-polyval(p,x),';residuals;',xf,dyf,'g-;;',xf,-dyf,'g-;;'); | 35 ## plot(x,y-polyval(p,x),';residuals;',xf,dyf,'g-;;',xf,-dyf,'g-;;'); |
33 | 36 |
34 ## Author: Paul Kienzle | |
35 ## This program is granted to the public domain. | |
36 function [y,dy] = polyconf(p,x,varargin) | 37 function [y,dy] = polyconf(p,x,varargin) |
37 alpha = s = []; | 38 alpha = s = []; |
38 typestr = 'pi'; | 39 typestr = 'pi'; |
39 for i=1:length(varargin) | 40 for i=1:length(varargin) |
40 v = varargin{i}; | 41 v = varargin{i}; |
43 elseif isscalar(v), alpha = v; | 44 elseif isscalar(v), alpha = v; |
44 else s = []; | 45 else s = []; |
45 end | 46 end |
46 end | 47 end |
47 if (nargout>1 && (isempty(s)||nargin<3)) || nargin < 2 | 48 if (nargout>1 && (isempty(s)||nargin<3)) || nargin < 2 |
48 usage("[y,dy] = polyconf(p,x,s,alpha,['ci'|'pi'])"); | 49 print_usage; |
49 end | 50 end |
50 | 51 |
51 if isempty(s) | 52 if isempty(s) |
52 y = polyval(p,x); | 53 y = polyval(p,x); |
53 | 54 |