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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? optimtips.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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲男人天堂av| 欧美一区二区三区四区高清| 精品国产乱码久久久久久1区2区 | 69精品人人人人| 亚洲美女偷拍久久| 成人av电影在线观看| 国产精品欧美久久久久无广告| 婷婷夜色潮精品综合在线| 色综合久久天天| 亚洲综合图片区| 在线欧美一区二区| 亚洲第一电影网| 欧美日韩国产三级| 五月婷婷色综合| 欧美亚洲动漫精品| 午夜精品视频一区| 欧美理论片在线| 麻豆国产精品官网| 欧美一级夜夜爽| 九一九一国产精品| 久久众筹精品私拍模特| 国产高清一区日本| 国产精品成人一区二区三区夜夜夜| 国产a久久麻豆| 亚洲欧洲日韩av| 一本一道波多野结衣一区二区| 亚洲毛片av在线| 欧美色手机在线观看| 亚洲v中文字幕| 亚洲精品在线观看网站| 东方aⅴ免费观看久久av| 亚洲欧美福利一区二区| 精品国产乱码久久久久久蜜臀| 亚洲va天堂va国产va久| 91精品国产综合久久小美女| 国产毛片精品视频| 国产精品天干天干在线综合| 91国偷自产一区二区三区成为亚洲经典| 亚洲一区二区三区四区在线免费观看 | 成人性生交大合| 最新国产精品久久精品| 欧美日韩国产首页| 国产在线播放一区| 亚洲少妇最新在线视频| 欧美一区二区三区四区在线观看| 国内精品久久久久影院薰衣草 | 紧缚捆绑精品一区二区| 亚洲三级免费电影| 日韩一区二区在线观看视频播放| 粉嫩av一区二区三区在线播放| 亚洲一区二区三区在线| 精品电影一区二区| 日本韩国欧美国产| 国产一区二区三区四区在线观看 | 日韩精品电影在线观看| 中文字幕不卡在线观看| 日韩丝袜情趣美女图片| 欧美三级日韩三级| 色吧成人激情小说| 欧美性大战久久| 另类成人小视频在线| 午夜av区久久| 一区二区三区日韩在线观看| 中文字幕亚洲一区二区av在线| 欧美大尺度电影在线| 日韩三级在线免费观看| 欧美一区二区在线看| 欧美日韩激情一区二区三区| 日本高清成人免费播放| 91色|porny| 91在线观看一区二区| 懂色一区二区三区免费观看| 丁香网亚洲国际| 国产福利91精品| 国产盗摄视频一区二区三区| 激情图区综合网| 国产一区二区视频在线| 国产一区二区导航在线播放| 国产在线视视频有精品| 国产精品一区免费视频| 国产精品综合视频| 顶级嫩模精品视频在线看| 成人小视频免费观看| av一二三不卡影片| 色综合天天视频在线观看| 在线影院国内精品| 欧美日韩一区国产| 欧美丰满高潮xxxx喷水动漫| 91精品午夜视频| 欧美不卡123| 欧美精品少妇一区二区三区| 天天综合天天综合色| 日本欧美在线观看| 国产一区二区三区国产| 国产成人免费视频| 日本久久电影网| 在线成人午夜影院| 久久午夜色播影院免费高清| 中文字幕av一区二区三区| 亚洲精品久久嫩草网站秘色| 亚洲成av人综合在线观看| 老司机午夜精品| 高清不卡一区二区| 欧美亚日韩国产aⅴ精品中极品| 欧美蜜桃一区二区三区| 久久免费美女视频| 亚洲免费av在线| 青青草国产成人99久久| 国产91丝袜在线播放| 在线观看视频欧美| 日韩精品一区二区在线| 亚洲欧洲成人自拍| 日韩精品欧美精品| 国产成人8x视频一区二区| 欧美亚洲动漫制服丝袜| 精品日韩成人av| 亚洲嫩草精品久久| 精品一区二区三区免费视频| kk眼镜猥琐国模调教系列一区二区| 欧美三级在线看| 在线观看av不卡| 亚洲老妇xxxxxx| 国产99久久久久| 在线观看一区二区精品视频| 欧美一级国产精品| 亚洲区小说区图片区qvod| 日日夜夜精品视频免费| 成人av在线电影| 欧美xxxx在线观看| 亚洲国产视频在线| 丁香婷婷深情五月亚洲| 欧美一区二区三区视频在线| 亚洲桃色在线一区| 激情五月激情综合网| 欧美精品三级在线观看| 国产精品久久三| 九色综合狠狠综合久久| 欧美日本一区二区在线观看| 中文字幕一区二区三区四区 | 91麻豆免费看片| 精品国产一区二区亚洲人成毛片 | 国产精品一区专区| 欧美日韩国产大片| 亚洲另类春色国产| av激情综合网| 久久精品欧美一区二区三区不卡 | 成人精品视频一区二区三区尤物| 91精品国产综合久久久蜜臀图片| 国产精品国产三级国产三级人妇| 精品一区二区在线视频| 9191久久久久久久久久久| 亚洲精品视频免费看| av中文字幕亚洲| 国产免费久久精品| 国产一区二区精品久久99| 精品日韩99亚洲| 蜜臀av国产精品久久久久| 欧美二区三区的天堂| 亚洲精品久久嫩草网站秘色| 色综合视频在线观看| ...xxx性欧美| 91麻豆.com| 最新日韩av在线| 色婷婷激情一区二区三区| 亚洲欧美日韩一区| 色哟哟国产精品| 亚洲美女屁股眼交3| 色美美综合视频| 亚洲精品国产无套在线观| 91丨porny丨中文| 亚洲免费观看高清| 91色porny蝌蚪| 亚洲一区二区三区爽爽爽爽爽| 一本久道中文字幕精品亚洲嫩| 亚洲欧美另类图片小说| 色婷婷久久久久swag精品| 亚洲一线二线三线久久久| 欧美日韩综合一区| 日本美女一区二区三区视频| 日韩一卡二卡三卡| 国产一区二区日韩精品| 国产欧美一区二区精品婷婷| 成人av在线播放网站| 一区二区三区影院| 欧美午夜宅男影院| 丝袜亚洲另类丝袜在线| 日韩免费福利电影在线观看| 国产精品一区二区在线播放| 中文字幕欧美区| 色婷婷久久99综合精品jk白丝| 亚洲国产精品一区二区www在线 | 亚洲婷婷国产精品电影人久久| 91免费看视频| 亚洲国产乱码最新视频| 欧美一级午夜免费电影| 国产精品18久久久久久久久 | 夜夜揉揉日日人人青青一国产精品| 欧美日韩精品是欧美日韩精品| 美女网站一区二区| 国产日韩av一区二区|