科学计算科学计算 (33).pdf
《科学计算科学计算 (33).pdf》由会员分享,可在线阅读,更多相关《科学计算科学计算 (33).pdf(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、5.5 Curve Fitting5.5 Curve FittingCase of population forecastPrinciples of curve fittingImplementation of curve fittingPractical applicationYear179018001810182018301840185018601870188018901900Population(million)3.95.37.29.612.917.123.231.438.650.263.076.0Year19101920193019401950196019701980199020002
2、010Population(million)92.0105.7122.8131.7150.7179.3203.2226.5248.7281.4308.71.1.Case of population Case of population forecastforecastPopulation growth is a popular concern in the world today.Forecasting population growthtrends is a common practice in every country.The data for a countrys censuses b
3、etween 1790and 2010 is shown in the table below.Please forecast population of the country in 2020.Solving ideas:Find a function to approximate these data,and then calculate the value of theprediction point based on the function found.x=1790:10:2010;y=3.9,5.3,7.2,9.6,12.9,17.1,23.2,31.4,38.6,50.2,63.
4、0,76.0,92.0,105.7,122.8,131.7,150.7,179.3,203.2,226.5,248.7,281.4,308.7;plot(x,y,*);p=polyfit(x,y,3);polyval(p,2020)plot(x,y,*,x,polyval(p,x);ans=339.8Two questions:(1)What kind of function is adopted as approximating function?polynomial function(2)How to calculate the minimum error?least square met
5、hodxx1x2xkxnyy1y2ykyny=f(x)y=g(x)Create a function g(x)to approximate f(x),and minimize the error under some condition.i=g(xi)-f(xi)(i=1,2,3,n)2.Principles of curve fitting2.Principles of curve fittingSimilar to data interpolation,curve fitting is also a method of function approximation.The least sq
6、uare method is a mathematical optimization technique.By minimizing thesum of squares of errors,it can find the best function matching for the data.Assume p(x)is a polynomial functionp(x)=amxm+am-1xm-1+a1x+a0If the value ofis minimal,then p(x)is the approximation function of the original function.()2
7、1p xyiiin=3.Implementation of curve fitting3.Implementation of curve fittingIn MATLAB,the function used for polynomial fitting is the polyfit function.The aim of thisfunction is to figure out the coefficients of fitting polynomial with the least squared errors.Itssyntax is:(1)P=polyfit(X,Y,m)(2)P,S=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 科学计算科学计算 33 科学 计算 33
限制150内