曲线拟合讲稿讲解

上传人:我** 文档编号:117216949 上传时间:2019-12-05 格式:PPT 页数:69 大小:614KB
返回 下载 相关 举报
曲线拟合讲稿讲解_第1页
第1页 / 共69页
曲线拟合讲稿讲解_第2页
第2页 / 共69页
曲线拟合讲稿讲解_第3页
第3页 / 共69页
曲线拟合讲稿讲解_第4页
第4页 / 共69页
曲线拟合讲稿讲解_第5页
第5页 / 共69页
点击查看更多>>
资源描述

《曲线拟合讲稿讲解》由会员分享,可在线阅读,更多相关《曲线拟合讲稿讲解(69页珍藏版)》请在金锄头文库上搜索。

1、曲线拟合 插值与拟合的相同点 都需要根据已知数据构造函数。 可使用得到函数计算未知点的函数值。 插值与拟合的不同点 插值: 过点; (适合精确数据) 拟合: 不过点, 整体近似;(适合有经验公式或 有误差的数据) 对实验数据进行拟合时,函数形式通常已 知,仅需要拟合参数值。 曲线拟合问题的提法 已知一组(二维)数据,即平面上已知一组(二维)数据,即平面上 n n个点(个点( x x i i , ,y y i i ) ) i i=1,=1,n n, , 寻求一个函数(曲线)寻求一个函数(曲线)y y= =f f( (x x), ), 使使 f f( (x x) ) 在在某种准则下与所有数据点最为

2、接近某种准则下与所有数据点最为接近 ,即曲线拟合得最好,即曲线拟合得最好 这种构造近似函数的方法称为曲线拟合,这种构造近似函数的方法称为曲线拟合, f f( (x x) ) 称为称为拟合函数拟合函数 拟合的标准 (1)用各点误差绝对 值的和表示 (2)用各点误差按绝 对值的最大值表示 (3)用各点误差的平 方和表示 最小二乘拟合 式中 R2 称为均方误差。由于计算均方误差 的最小值的原则容易实现而被广泛采用。 按均方误差达到极小构造拟合曲线的方法 称为最小二乘法。 拟合与回归的比较 回归是关于离回归平方和最小(即最小二 乘法)作为目标函数的模型系数求算方法 。 而拟合可能有其他的目标函数如绝对

3、差值 之和最小等目标函数。 但绝大多数也是以离回归平方和最小为目 标函数,此时两者没有任何差别,只是提 法上的不同。 线性最小二乘法的基本思路 第一步第一步: :先选定一组函数先选定一组函数 r r 1 1 ( (x x), ), r r 2 2 ( (x x), ,), ,r rm m( (x x), ), mm n n, , 令令 f f( (x x)=)=a a 1 1r r1 1 ( (x x)+)+a a 2 2r r2 2 ( (x x)+ +)+ +a am m r r mm( (x x) ) ( (1 1) 其中其中 a a 1 1, ,a a2 2 , , ,a am m 为

4、待定系数 为待定系数 第二步第二步: : 确定确定a a 1 1, ,a a2 2 , , ,a am m 的 的准则(最小二乘准则准则(最小二乘准则 ):使):使n n个点个点(x x i i , ,y y i i ) ) 与与曲线曲线 y y= =f f( (x x) ) 的的距离距离 i i 的平的平 方和最小方和最小 线性最小二乘法的基本思路 记记 问题归结为,求问题归结为,求 a a 1 1, ,a a2 2 , , ,a am m 使 使 J J ( (a a 1 1, ,a a2 2 , , ,a am m ) ) 最小最小 J J ( (a a 1 1, ,a a2 2 , ,

5、 ,a am m) )分别对 分别对a a 1 1, ,a a2 2 , , ,a am m 求偏 求偏 导并令其为导并令其为0 0,得方程组,得方程组 线性最小二乘法的基本思路 R RT T RaRa= =R R T T y y 当当R R T T R R可逆时,方程组的解为:可逆时,方程组的解为:a a=(=(R R T TR R) ) -1-1 R RT T y y 其中其中 线性最小二乘拟合 f(x)=a1r1(x)+ +amrm(x)中 函数r1(x),rm(x)的选取 1. 通过机理分析建立数学模型来确定 f(x); + + + + + + + + + + + + + + + +

6、+ + + + + + + + + + + + + + f=a1+a2x f=a1+a2x+a3x2 f=a1+a2x+a3x2 f=a1+a2/xf=aebx f=ae-bx 2. 将数据 (xi,yi) i=1, ,n 作图,通过直观判断确定 f(x): 用MATLAB作拟合 Matlab有一个功能强大的曲线拟合工具箱 (Curve Fitting Toolbox ) cftool, 使用 方便,能实现多种类型的线性、非线性曲 线拟合。 调用语法 cftool cftool(xdata,ydata) 界面如下所示 “Data”按钮 点击“Data”按钮,弹出“Data”窗口; 利用X da

7、ta和Y data的下拉菜单读入数据 x,y,可修改数据集名“Data set name”, 然后点击“Create data set”按钮,退出 “Data”窗口,返回工具箱界面,这时会自 动画出数据集的曲线图; “Fitting”按钮 点击“Fitting”按钮,弹出“Fitting”窗口; 点击“New fit”按钮,可修改拟合项目名称 “Fit name”,通过“Data set”下拉菜单选 择数据集,然后通过下拉菜单“Type of fit” 选择拟合曲线的类型。 Custom Equations 用户自定义的函数类型 Linear equations are defined as

8、equations that are linear in the parameters. (例如: y=a*(sin(x - pi)+c)For example, the polynomial library equations are linear. Functions that depend only on the independent variable and constants. Note that if you attempt to define a term that contains a coefficient to be fitted, an error is returne

9、d. Custom Equations 用户自定义的函数类型 General (nonlinear) equations are defined as equations that are nonlinear in the parameters, or are a combination of linear and nonlinear in the parameters. For example, the exponential library equations are nonlinear. 例如:Y=a*exp(-b*x)+c Exponential指数函数 A one-term or t

10、wo-term exponential equation. 有2种类型 a*exp(b*x) a*exp(b*x) + c*exp(d*x) Fourier傅立叶函数 Sums of sines and cosines from one sum up to eight sums. 有8种类型,基础型是 a0 + a1*cos(x*w) + b1*sin(x*w) Gaussian高斯函数 Sums of Gaussians up to eight peaks. 有8种类型,基础型是 a1*exp(-(x-b1)/c1)2) Interpolant插值 有4种类型 Linear nearest

11、neighbor cubic spline shape-preserving Polynomial多项式函数 Polynomial equations from linear to ninth degree. 有9种类型 linear Polynomial quadratic Polynomial cubic Polynomial 4-9th degree Polynomial Power幂函数 有2种类型 a*xb a*xb + c Rational有理数函数 Ratios of polynomials up to degree five in both numerator(分子) and

12、denominator(分母). 分子、分母共有的类型是linear polynomial、quadratic polynomial、 cubic polynomial、4-5th degree polynomial; 此外,分子还包括constant型 Smoothing Spline平滑样条 A piecewise polynomial that varies from linear to cubic. You adjust the level of smoothing with the smoothing parameter. The default parameter value de

13、pends on the data and often produces the smoothest fit. 平滑参数介于01,越大越平滑,取0时为 一次多项式拟合。 Sum of Sin Functions正弦曲线 Sums of sines from one function up to eight functions. 有8种类型,基础型是 a1*sin(b1*x + c1) Weibull韦伯曲线 The two-parameter Weibull distribution 只有一种 a*b*x(b-1)*exp(-a*xb) Weibull分布的密度函数,k为形状参数,l 为尺度参

14、数 Weibull分布的密度曲线 Results 复选框 Displays detailed results for the current fit including the fit type (model, spline, or interpolant), the fitted coefficients and 95% confidence bounds for parametric fits, and these goodness of fit statistics: 下面是个例子 Results 复选框 Linear model Poly2: f(x) = p1*x2 + p2*x +

15、 p3 Coefficients (with 95% confidence bounds): p1 = 1.376 (-0.1468, 2.898) p2 = -0.4619 (-2.126, 1.202) p3 = 0.5758 (0.2052, 0.9463) Goodness of fit: SSE: 2.308 R-square: 0.5809 Adjusted R-square: 0.5499 RMSE: 0.2924 SSE The sum of squares due to error. This statistic measures the deviation of the responses from the fitted values of the responses. A value closer to 0 indicates a better fit. 偏差平方和,越接近0越好 R-square The coefficient of multiple determination. This statistic measures how successful the fit is in explaining the variation of the data. A value clo

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号