亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? optimtips_0_20.m

?? New users and old of optimization in MATLAB will find useful tips and tricks in this document, as we
?? M
?? 第 1 頁 / 共 5 頁
字號:
%{Regression and optimization tips & tricks of the trade - usingmatlab and the optimization toolbox in ways that you may never haveconsidered. Think of this text as a Matlab work book. I've includedthe tricks I see asked about many times on the comp.soft-sys.matlabnewsgroup. If I've left out your favorite trick, just drop me a lineand I'll try to add it in. This article is not intended as a FAQhowever. Much of what I'll say in here has to do with curve-fitting andparameter estimation. It is after all a fertile source ofoptimization problems. I'll do my best to look at as many ofthe different optimizers as possible. This may help a noviceoptimizer to use the solutions found in this text as a set oftemplates for their problems.Is the order of the topics I've chosen important? I've tried to makeit all flow as well as possible, but I won't always succeed. Feelfree to skip to the section that holds your own interest.Apologies are due to my readers who live with a release of Matlabolder than release 14. Almost all of the examples here are writtenusing anonymous functions. Luckily, most of these examples willstill be quite readable, so all may not be lost. If I hear enoughrequests I may be willing to expand these examples, includingversions which are accessible to users of older releases.Using this workbookThis text is written with matlab's cell mode in mind. Each sectionhas blocks of executable code that are surrounded with a %% beforeand after. This allows you to execute that block directly in matlab.Anything that I want to say inside a block will be in the form ofa matlab comment. Users of matlab releases that do not supportcell mode can always use copy and paste to execute these blocksof matlab commands.I've also used the block comment form, %{ and %}, which became an option in release 14 of matlab. In effect, every line of thisarticle is either an executable line of matlab code, or a validmatlab comment. Users of older releases will just have to forgiveme once more.If you do have release 14 or beyond, then try "Publish to HTML".Its an option on the editor's file menu, or a button on the editortask bar. Give Matlab a minute or two to run through all of myexamples, then matlab produces a nice document that can be readthrough at your leisure.%}%% 1. Linear regression basics in matlab%{I'll start with some linear regression basics. While polyfit doesa lot, a basic understanding of the process is useful.Lets assume that you have some data in the form y = f(x) + noise.We'll make some up and plot it.%}%%% Execute this cell.x = sort(rand(20,1));y = 2 + 3*x + randn(size(x));plot(x,y,'o')title 'A linear relationship with added noise'%%% We'd like to estimate the coefficients of this model from the data.% Many books show a solution using the normal equations.M = [ones(length(x),1),x];% These are the normal equations.coef = inv(M'*M)*M'*y% coef contains regression estimates of the parametersyhat = M*coef;plot(x,y,'o',x,yhat,'-')title 'Linear regression model'%%% A better solution uses \. Why? Because \ is more numerically% stable than is inv. Its something you will appreciate one day% when your data is nasty. In this case, the different methods% will be indistinguishable. Use \ anyway. disp 'Use of \'coef2 = M\y%%% Pinv is also an option. It too is numerically stable, but it% will yield subtly different results when your matrix is singular% or nearly so. Is pinv better? There are arguments for both \ and% pinv. The difference really lies in what happens on singular or% nearly singular matrixes. See the sidebar below.% Pinv will not work on sparse problems, and since pinv relies on% the singular value decomposition, it may be slower for large% problems.disp 'Use of pinv'coef3 = pinv(M)*y% Large-scale problems where M is sparse may sometimes benefit% from a sparse iterative solution. An iterative solver is overkill% on this small problem, but ...disp 'Use of lsqr'coef4 = lsqr(M,y,1.e-13,10)% There is another option, lscov. lscov is designed to handle problems% where the data covariance matrix is known. It can also solve a% weighted regression problem (see section 2.)disp 'Use of lscov'coef5 = lscov(M,y)%%% Directly related to the \ solution is one based on the QR% factorization. If our over-determined system of equations to% solve is M*coef = y, then a quick look at the normal equations,%%   coef = inv(M'*M)*M'*y%% combined with the qr factorization of M,%%   M = Q*R%% yields%%   coef = inv(R'*Q'*Q*R)*R'*Q'*y%% Of course, we know that Q is an orthogonal matrix, so Q'*Q is% an identity matrix.%%   coef = inv(R'*R)*R'*Q'*y%% If R is non-singular, then inv(R'*R) = inv(R)*inv(R'), so% we can further reduce to%%   coef = inv(R)*Q'*y%% Finally, recognize that this is best written in matlab% (especially for upper triangular R) as%%   coef = R\(Q'*y)%% Why show this solution at all? Because later on, when we discuss% confidence intervals on the parameters, this will prove useful.disp 'Use of an explicit qr factorization'[Q,R] = qr(M,0);coef6 = R\(Q'*y)%%% Note that when we generated our data above, we added random noise% using the function randn. Randn generates uncorrelated Gaussian% (normally distributed) noise. In fact, the model that we chose% was the correct model for our data. In some cases the choice of% model will be only a guess.x2 = sort(rand(50,1));y2 = 1 + 2*x2 - 4*x2.^2 + randn(size(x2))/10;% lets fit this data with our same linear model.M2 = [ones(length(x2),1),x2];coef = M2\y2% and plot the resultsyhat2 = M2*coef;plot(x2,y2,'o',x2,yhat2,'-')title 'Linear model through quadratic data'%%% Plotting the residuals shows the clear lack of fit in our model. % I'll leave any more discussion of basic regression analysis to a% good text on the subject. Draper and Smith, "Applied regression% Analysis" was always a favorite of mine.res2 = y2 - yhat2;plot(x2,res2,'o')title 'Residuals for a linear model through quadratic data'%%% Sidebar: Pinv uses a singular value decomposition, whereas \% uses a qr factorization for non-square matrices. The difference?% lets try out the alternative solutions on a singular problem,% with no noise in the data.M = rand(10,2);M = M(:,[1 2 2]);y = sum(M,2);disp 'Singular matrix: pinv'coef1 = pinv(M)*ydisp 'Singular matrix: \'coef2 = M\ydisp 'Singular matrix: lsqr'coef3 = lsqr(M,y)disp 'Singular matrix: lscov'coef4 = lscov(M,y)% Lsqr produces a solution with pinv-like characteristics, while% lscov is clearly similar to \.%%% Note that \ gave a warning of rank deficiency, and that since% the second and third columns of M were replicates, the two% solutions are really equivalent. Except that \ resulted in a% zero coefficient for the third column. Pinv has the property% that in the case of singularity, it will produce the minimum% norm solution.[norm(coef1),norm(coef2)]% Either solution [1 1 1]' or [1 2 0]' was equally valid, but the% pinv solution had a lower norm.%% 2. Polynomial regression models%{Arguably the most common linear regression model is the polynomialmodel. In a simple case, we may wish to estimate the coefficients(a and b) of the model  y = a*x + bAs I showed in the previous section, this is easily done using \,or any of a variety of other tools in matlab. We could also havedone the regression estimation using polyfit.Note that polyfit returns its polynomial with terms in orderfrom the highest power down.You can also build more general polynomial models, with your choiceof terms, or in multiple dimensions using polyfitn. Its here onthe file exchange:http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10065&objectType=FILE%}%% % A linear model estimated using polyfitx = sort(rand(20,1));y = 3*x + 2 + randn(size(x));p = polyfit(x,y,1)%% 3. Weighted regression models%{What do you do when you have weights? How should we interpretregression weights anyway? Suppose we knew one particular data point had much lower errorthan the rest. We might just choose to replicate that data pointmultiple times. That replicated point will drag the sums ofsquares of errors around. Lets try it out.%}%% x = sort(rand(20,1));y = 2 + 3*x + randn(size(x));% replicating the point (1,5) 20 timesnreps = 20;x2 = [x;ones(nreps,1)];y2 = [y;repmat(5,nreps,1)];% and solveM2 = [ones(size(x2)),x2];coef = M2\y2yhat = M2*coef;closeplot(x2,y2,'o',x2,yhat,'-')title 'A weighted regression, weighting by replication'% note that the error in the replicated point was probably pretty% small, much lower than the rest of the data.%%% We can emulate this point replication using a weighted regression.% Note the sqrt(nreps) in this approach to the weighted regression.x3 = [x;1];y3 = [y;5];nreps = 20;weights = [ones(size(y));sqrt(nreps)];M3 = [ones(size(x3)),x3];% Just multiply each row of M and the corresponding y by its weight.coef = (repmat(weights,1,2).*M3)\(weights.*y3)%%% Weighted regression is one of the abilities of lscov.weights = [ones(size(y));nreps];coef = lscov(M3,y3,weights)%%% Are regression weights really used as a description of the known% variance of your data? Clearly the examples above show that% weights are interpreted as a relative replication factor. Thus% a weight of k for a point is equivalent to having replicated the% given point k times.% Does this mean that a weighted regression with all its weights% equal to some large value will yield a different result?n=20;x = sort(rand(n,1));y = 2 + 3*x + randn(size(x));M = [ones(n,1),x];% The unweighted resultcoef0 = lscov(M,y)%%% With weights all equal to 10w = 10;weights = w*ones(n,1);coef1 = lscov(M,y,weights)% Likewise, any confidence limits derived for the model will also% be unchanged.% Thus weights in this context are PURELY relative weights. Doubling% all of the weights will not reflect any overall belief on your% part that the data is more accurate. %% 4. Robust estimation %{Outliers are the source of many difficulties for estimation problems.Least squares estimation, linear or nonlinear, will be dragged aroundby points with large residuals. If these large residual points do notarise because of the expected normal distribution, but actually arisefrom some other distribution mixed in, then the least squares estimatesmay well be wildly off.In this case, some sort of trimming or iterative re-weighting schememay be appropriate. Iterative re-weighting simply means to computea regression model, then generates weights which are somehow inverselyrelated to the residual magnitude. Very often this relationship willbe highly nonlinear, perhaps the 5% of the points with the largestresiduals will be assigned a zero weight, the rest of the pointstheir normal weight. Then redo the regression model as a weightedregression.%}%%n = 50;m = 5;x = rand(n,1);y = 2 + 3*x + randn(size(x))/10;% Now mix in a few outliers. Since the data is in random order,% just add some noise to the first few data points.y(1:m) = y(1:m) + exp(rand(m,1)*3);closeplot(x,y,'o')title 'Outliers in the data'%%% Fit with a simple first order linear modelM = [ones(n,1),x];coef0 = M\y%%% Compute the residuals for the current model, then make up some% weights based on the residuals, then fit. Iterate a few times.for i=1:3  res = M*coef0 - y;  weights = exp(-3*abs(res)/max(abs(res)))';  % compute the weighted estimate using these weights  coef1 = lscov(M,y,weights)  coef0=coef1;end%{This final estimate of coef1 will usually be closer to the known coefficients than the first (unweighted) estimate.I chose to a fairly arbitrary weight transformation. For thosewho are interested, potentially better choices may be found inone of these texts:"Robust Statistics", P.J. Huber"Data Analysis and Regression: A Second Course in Statistics",F. Mosteller, J.W. Tukey"Understanding Robust and Exploratory Data Analysis", D.C. Hoaglin

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲自拍偷拍综合| 亚洲黄色录像片| 亚洲激情在线激情| 激情丁香综合五月| 欧美亚洲国产bt| 欧美国产一区视频在线观看| 亚洲国产欧美一区二区三区丁香婷| 久久99精品网久久| 欧美性猛片xxxx免费看久爱| 26uuu亚洲综合色欧美 | 不卡av在线免费观看| 91麻豆精品国产91久久久使用方法| 久久久精品欧美丰满| 天天免费综合色| 一本一道综合狠狠老| 国产日产欧美一区| 美女脱光内衣内裤视频久久网站| 在线观看免费成人| 亚洲同性gay激情无套| 国产福利一区二区三区| 日韩欧美一级二级| 亚洲国产精品一区二区久久恐怖片| 成人久久视频在线观看| 亚洲精品在线观看视频| 日本人妖一区二区| 欧美视频一区二区在线观看| 亚洲三级免费电影| 成人av网站大全| 国产精品天干天干在线综合| 激情综合五月婷婷| 精品99999| 国产综合色视频| 欧美精品一区二区不卡 | 国产精品911| 精品久久人人做人人爽| 久久99国产精品免费| 日韩一区二区视频| 喷水一区二区三区| 日韩精品中午字幕| 精品一区二区三区蜜桃| 精品国产1区2区3区| 久久激情五月婷婷| 国产日产欧美一区二区视频| 国产成a人无v码亚洲福利| 亚洲国产精品二十页| 粉嫩av一区二区三区粉嫩| 国产精品久久久久久久第一福利| 成人avav影音| 国产福利一区二区三区在线视频| 精品国产乱码久久久久久蜜臀 | 日韩一级精品视频在线观看| 全部av―极品视觉盛宴亚洲| 日韩欧美成人一区二区| 激情五月婷婷综合网| 久久日韩精品一区二区五区| 国产不卡视频一区二区三区| 中文字幕久久午夜不卡| 91国偷自产一区二区使用方法| 亚洲国产美国国产综合一区二区| 日韩一区二区三区在线| 国产激情偷乱视频一区二区三区| 国产精品污www在线观看| 色欧美88888久久久久久影院| 视频在线观看91| 国产亚洲一区字幕| 色成年激情久久综合| 日本视频免费一区| 国产精品色在线观看| 欧美综合欧美视频| 国产最新精品精品你懂的| 亚洲精品视频免费看| 日韩精品一区二区三区视频在线观看 | 精品区一区二区| www.成人在线| 麻豆精品精品国产自在97香蕉| 日本一区二区久久| 欧美精品自拍偷拍动漫精品| 成人听书哪个软件好| 三级不卡在线观看| 亚洲欧美综合另类在线卡通| 日韩一区二区麻豆国产| 91麻豆国产精品久久| 韩国v欧美v日本v亚洲v| 亚洲成人在线网站| 亚洲欧美在线aaa| 欧美成人高清电影在线| 欧美在线综合视频| 高清beeg欧美| 久草在线在线精品观看| 亚洲国产精品久久一线不卡| 久久av中文字幕片| 一区二区欧美视频| 国产精品女上位| 精品国一区二区三区| 欧美日韩一区二区在线视频| www.欧美日韩国产在线| 国产成人综合精品三级| 久久国产精品免费| 日韩高清电影一区| 亚洲二区在线观看| 一区二区理论电影在线观看| 国产精品毛片大码女人| 国产人伦精品一区二区| 精品国精品国产| 日韩精品在线网站| 欧美一区二区免费视频| 91麻豆精品国产| 欧美无砖砖区免费| 欧美性大战久久久久久久| 99re成人在线| 波多野结衣中文字幕一区二区三区| 狠狠色丁香婷婷综合| 狠狠色丁香久久婷婷综| 激情综合网天天干| 精品在线视频一区| 国产在线播放一区| 国产麻豆精品视频| 国产精品一品二品| 国产99久久久国产精品潘金| 国产精品亚洲午夜一区二区三区| 激情综合色综合久久| 国产一区啦啦啦在线观看| 国产美女一区二区三区| 国产老女人精品毛片久久| 国产精品99久久久久久有的能看 | 亚洲美女免费视频| 亚洲一区二区三区四区在线| 一区二区三区视频在线观看| 亚洲成人精品一区二区| 麻豆国产欧美一区二区三区| 国产揄拍国内精品对白| 成人午夜视频在线观看| av在线综合网| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 国产午夜亚洲精品不卡| 国产精品久久久久久久第一福利| 亚洲激情网站免费观看| 视频一区在线播放| 国产乱淫av一区二区三区| 成人动漫av在线| 欧美区视频在线观看| 精品黑人一区二区三区久久| 一区精品在线播放| 丝袜美腿亚洲色图| 国产91精品欧美| 欧美视频在线观看一区| 欧美www视频| 亚洲欧美日韩久久| 美女视频黄 久久| 成人午夜激情在线| 欧美精品第一页| 欧美激情一区二区三区不卡| 亚洲中国最大av网站| 久久精品99国产国产精| 91美女福利视频| 精品国产乱码久久久久久久 | 欧美mv日韩mv| 亚洲靠逼com| 久99久精品视频免费观看| 91在线观看一区二区| 欧美成人性战久久| 亚洲欧美日韩国产手机在线| 免费观看一级欧美片| av在线不卡观看免费观看| 欧美日韩电影在线| 中文字幕亚洲电影| 另类的小说在线视频另类成人小视频在线 | 天天色图综合网| 成人高清视频在线| 欧美大片日本大片免费观看| 中文字幕佐山爱一区二区免费| 日韩av在线发布| 欧美视频一区二区三区| 国产精品美女视频| 国产主播一区二区| 欧美一区二区在线不卡| 亚洲综合视频在线观看| www.一区二区| 国产欧美一区二区三区鸳鸯浴 | 精品成a人在线观看| 亚洲gay无套男同| 一本大道av一区二区在线播放| 久久综合久色欧美综合狠狠| 天堂在线一区二区| 在线亚洲精品福利网址导航| 国产精品久久久久四虎| 国产美女主播视频一区| 日韩欧美激情在线| 男男成人高潮片免费网站| 欧美日韩国产首页| 亚洲一二三专区| 欧美午夜精品免费| 一区二区欧美视频| 欧美天堂一区二区三区| 亚洲人成网站精品片在线观看| 国产91对白在线观看九色| 久久久久久一二三区| 国产一区999| 欧美国产日韩在线观看| 大胆亚洲人体视频|