日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

用matlab参数法拟合,MATLAB|曲线拟合基本介绍

發布時間:2024/10/5 循环神经网络 70 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用matlab参数法拟合,MATLAB|曲线拟合基本介绍 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

曲線擬合工具箱cftool基本介紹

Tips

mathworks官網的和help文件

https://cn.mathworks.com/help/curvefit/fit-comparison-in-curve-fitting-app.html

在mathworks官網找到相應的help文件,點擊右上角的Translate This Page,可以查看中文翻譯,雖然是自動翻譯的,很不準確,但偶爾可以看看。

☆曲線擬合工具箱界面

☆☆操作方法

在命令行輸入數據:

x

y

啟動曲線擬合工具箱

命令:cftool

進入曲線擬合工具箱界面“Curve Fitting tool”

1)利用X data和Y data的下拉菜單讀入數據x,y

2)選擇曲線擬合類型

3)自動擬合 即可在結果窗口和曲線窗口顯示出擬合結果

工具箱提供的擬合類型如下,進行簡要說明,可以嘗試各種不同類型擬合效果

Custom Equations:用戶自定義的函數類型

Exponential:指數逼近,有2種類型, aexp(bx) 、 aexp(bx) + cexp(dx)

Fourier:傅立葉逼近,有7種類型,基礎型是 a0 + a1cos(xw) + b1sin(xw)

Gaussian:高斯逼近,有8種類型,基礎型是 a1*exp(-((x-b1)/c1)^2)

Interpolant:插值逼近,有4種類型,linear、nearest neighbor、cubic spline、shape-preserving

Polynomial:多形式逼近,有9種類型,linear ~、quadratic ~、cubic ~、4-9th degree ~

Power:冪逼近,有2種類型,ax^b 、ax^b + c

Rational:有理數逼近,分子、分母共有的類型是linear ~、quadratic ~、cubic ~、4-5th degree ~;此外,分子還包括constant型

Smoothing Spline:平滑逼近(翻譯的不大恰當,不好意思)

Sum of Sin Functions:正弦曲線逼近,有8種類型,基礎型是 a1sin(b1x + c1)

Weibull:只有一種,a*b*x^(b-1)*exp(-a*x^b)

選擇View > Residuals Plot,可以查看殘差圖。

在Table of Fits中右擊選擇Duplicate “XX” (或者在Fit主菜單里面復制) 復制某個擬合,重新生成別的擬合,進行對比。

觀察Results以及residuals plot 殘差圖。

The residuals from a good fit should look random with no apparent pattern. A pattern, such as a tendency for consecutive residuals to have the same sign, can be an indication that a better model exists.

☆☆☆如何選取最好的擬合結果

To determine the best fit, you should examine both the graphical and numerical fit results.

第一步:查看圖的擬合結果【Examine the Graphical Fit Results】

殘差圖:越小,擬合越好。

選擇Tools > Axes Limits,或者直接點解Adjust Axes Limits圖標,調整加大x軸坐標,顯示曲線的變化趨勢,若擬合曲線的趨勢與預期趨勢一致(上升、下降),則表明擬合效果較好。

第二步:檢查數值結果【Evaluate the Numerical Fit Results】

擬合結果指標【Goodness of fit】(參見help: Evaluating Goodness of Fit)

在Table of Fits中雙擊某個指標可以排序。

SSE【the sum of squares due to error】:誤差平方和

R-square: 復相關系數或復測定系數

Adjusted R-square:調整自由度的復相關系數

RMSE【Root mean squared error】: 均方根誤差

The adjusted R-square statistic is generally the best indicator of the fit quality when you add additional coefficients to your model.

當SSE和RMSE越小,R越接近于1時標明擬合的越好。

☆☆☆☆其他操作

選擇Window > Left/Right Tile or Top/Bottom Tile(窗口>左/右平鋪或頂部/底部平鋪圖),可以對比擬合結果。

選擇View > Fit Settings or Table of Fits可以關閉Fit Settings、Table of Fits,只顯示圖形,進行對比。MATLAB help文件里有有個Note:

The fitted coefficients associated with the constant, linear, and quadratic terms are nearly identical for each normalized polynomial equation. However, as the polynomial degree increases, the coefficient bounds associated with the higher degree terms cross zero, which suggests overfitting.

對于多項式擬合,多項式階數越高,如果擬合系數的置信區間接近0,說明可能過度擬合了。。。

MATLAB中的fit函數

fit函數fit()

fitobject = fit(x,y,fitType,fitOptions)

擬合類型:擬合表達式expression

aFittype = fittype(expression,Name,Value)

fitoptions = fitoptions(libraryModelName,Name,Value)options =

Normalize: 'off'

Exclude: []

Weights: []

Method: 'NonlinearLeastSquares'

Robust: 'Off'

StartPoint: [1x0 double]

Lower: [0 -Inf 0 0 -Inf 0]

Upper: [1x0 double]

Algorithm: 'Trust-Region'

DiffMinChange: 1.0000e-08

DiffMaxChange: 0.1000

Display: 'Notify'

MaxFunEvals: 600

MaxIter: 400

TolFun: 1.0000e-06

TolX: 1.0000e-06

fitoption得出的各參數的意義:Normalize: 對數據歸一化處理

Exclude: 排除數據

Weights: 加權

Method: 擬合方法, 非線性最小二乘法

Robust: 穩健方式(通過加權方式排除異常值影響)

StartPoint: 擬合開始點

Lower: 擬合參數下界

Upper: 擬合參數上界

Algorithm: 算法 ‘置信區間’

DiffMinChange: 差分時參數最小變化值

DiffMaxChange: 差分時參數最大變化值

Display: 顯示通知

MaxFunEvals: 最大函數計算次數

MaxIter: 最大迭代次數

TolFun: 函數精度

TolX: 參數精度

MATLAB線性擬合函數polyfit、polyval、polyconf

參見:MATLAB簡單應用實例% 原始數據

data1; %x數據

data2; %y數據

% cftool查看

cftool(data1,data2);

% 多項式擬合

[pp1,ss1]=polyfit(data1,data2,1),%%一次多項式

nh_line=polyval(pp1,data1);%擬合曲線,相當于:nh_line=pp1(1,1).*data1+pp1(1,2);

% 得到具有75%保證率的直線

[yhat,delta]=polyconf(pp1,data1,ss1,0.25); %% 0.25表示1-0.25保證率

pp75=polyfit(data1,yhat+delta,1); %%公式

% 繪圖

figure;

plot(data1,data2,'ko');hold on; %原始數據

plot(data1,nh_line,'b-','LineWidth',2.5);% 擬合的一次曲線

plot(data1,yhat+delta,'r:','LineWidth',2.5);% 具有75%保證率的直線--上限

plot(data1,yhat-delta,'r:','LineWidth',2.5);% 具有75%保證率的直線--下限

推薦閱讀:

總結

以上是生活随笔為你收集整理的用matlab参数法拟合,MATLAB|曲线拟合基本介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。