9一次完成增广最小二乘算法Word格式文档下载.docx

上传人:b****6 文档编号:17298411 上传时间:2022-12-01 格式:DOCX 页数:33 大小:25.27KB
下载 相关 举报
9一次完成增广最小二乘算法Word格式文档下载.docx_第1页
第1页 / 共33页
9一次完成增广最小二乘算法Word格式文档下载.docx_第2页
第2页 / 共33页
9一次完成增广最小二乘算法Word格式文档下载.docx_第3页
第3页 / 共33页
9一次完成增广最小二乘算法Word格式文档下载.docx_第4页
第4页 / 共33页
9一次完成增广最小二乘算法Word格式文档下载.docx_第5页
第5页 / 共33页
点击查看更多>>
下载资源
资源描述

9一次完成增广最小二乘算法Word格式文档下载.docx

《9一次完成增广最小二乘算法Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《9一次完成增广最小二乘算法Word格式文档下载.docx(33页珍藏版)》请在冰豆网上搜索。

9一次完成增广最小二乘算法Word格式文档下载.docx

nb=2

nc=2

a[i]b[i]c[i]

a[1]=-1.493742b[1]=1.000714c[1]=-0.960678

a[2]=0.693381b[2]=0.500283c[2]=0.140650

z[i]=1.5*z[i-1]-0.7*z[i-2]+u[i-1]+0.5*u[i-2]+e[i]-e[i-1]+0.2*e[i-2]

其各阶相应的AIC值:

AIC1=266.721111

AIC2=-555.549342

(2)用仿真模型为:

z(k)–1.185z(k–1)+0.814z(k–2)–0.518z(k–3)+0.349z(k–4)-0.117z(k–5)

=1.08u(k–1)–0.745u(k–2)+0.475u(k–3)–0.253u(k–4)+0.123u(k–5)+e(k)–e(k–1)+0.2*e(k–2),

各阶的AIC值并不单调减少,而是有两个极小值点,后一个极小值是最小值。

取AIC值的第一个极小值为阶次递推结束的判断准则时(本程序中使用),用高阶CAR模型辨识时,参数基本一致,均为五阶;

再用CARMA模型辨识时,其阶次随M序列的起始位置的变化而变化,基本为二阶(与噪声模型阶次相同)。

如果取最小值,即第二个极小值为阶次递推结束的判断准则,用高阶CAR模型辨识时,参数也基本一致,均为七阶。

再用CARMA模型辨识时,其阶次随M序列的起始位置的变化而变化,或为二阶或为四阶。

取第一个极小值时最终结果如下。

1)CAR模型辨识(见数据文件sita_模型二_CAR.txt)

其各阶相应的AIC最终辨识结果为:

na=5

nb=5

a[1]=-0.223720b[1]=1.078827

a[2]=0.413757b[2]=0.281458

a[3]=-0.089438b[3]=0.535125

a[4]=0.133208b[4]=0.215608

a[5]=-0.042686b[5]=0.154680

z(k)-1.185z(k-1)+0.814z(k-2)-0.518z(k-3)+0.349z(k-4)-0.117z(k-5)

=1.08u(k-1)-0.745u(k-2)+0.475u(k-3)-0.253u(k-4)+0.123u(k-5)+e(k)-e(k-1)+0.2*e(k-2),

AIC1=-503.448058

AIC2=-512.867662

AIC3=-547.163204

AIC4=-574.337431

AIC5=-576.072235

2)CARMA模型辨识(见数据文件sita_模型二_CARMA.txt)

a[1]=-0.311358b[1]=1.082055c[1]=-0.105349

a[2]=-0.046363b[2]=0.190831c[2]=-0.508015

AIC1=-500.816897

AIC2=-546.201025

虽然辨识参数及辨识出的阶次跟实际模型相差很大,但辨识出的模型输出却跟实际输出接近,CAR模型跟CARMA模型的输出结果尤其接近。

(开始运行时输出的曲线为三种输出都有的曲线。

当用鼠标左键在界面内双击时,可循环显示CAR模型与CARMA模型输出曲线、CARMA模型与实际模型输出曲线、实际模型与CAR模型输出曲线及三者全部显示的曲线。

三组模型输出结果参见数据文件zzz.txt,e_CAR.txt表示CAR模型使用的白噪声与WhiteNoise2.txt相同,e_CARMA.txt表示CARMA模型使用的白噪声,由CAR模型辨识误差形成。

U.txt为实际使用的M序列(Mserials.txt)的子序列(随起始位置的变化而不同),z.txt为模型输出。

sita_模型、_CAR.txt和sita_模型、_CARMA.txt分别表示CAR模型和CARMA模型的辨识结果。

(3)源程序

//ELS_RO_AICDlg.cpp:

implementationfile

//

#include"

stdafx.h"

ELS_RO_AIC.h"

ELS_RO_AICDlg.h"

math.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

#defineA179

#definePAI3.1415926

/////////////////////////////////////////////////////////////////////////////

//CAboutDlgdialogusedforAppAbout

classCAboutDlg:

publicCDialog

{

public:

CAboutDlg();

//DialogData

//{{AFX_DATA(CAboutDlg)

enum{IDD=IDD_ABOUTBOX};

//}}AFX_DATA

//ClassWizardgeneratedvirtualfunctionoverrides

//{{AFX_VIRTUAL(CAboutDlg)

protected:

virtualvoidDoDataExchange(CDataExchange*pDX);

//DDX/DDVsupport

//}}AFX_VIRTUAL

//Implementation

protected:

//{{AFX_MSG(CAboutDlg)

//}}AFX_MSG

DECLARE_MESSAGE_MAP()

};

CAboutDlg:

:

CAboutDlg():

CDialog(CAboutDlg:

IDD)

//{{AFX_DATA_INIT(CAboutDlg)

//}}AFX_DATA_INIT

}

voidCAboutDlg:

DoDataExchange(CDataExchange*pDX)

CDialog:

DoDataExchange(pDX);

//{{AFX_DATA_MAP(CAboutDlg)

//}}AFX_DATA_MAP

BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)

//{{AFX_MSG_MAP(CAboutDlg)

//Nomessagehandlers

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

//CELS_RO_AICDlgdialog

CELS_RO_AICDlg:

CELS_RO_AICDlg(CWnd*pParent/*=NULL*/)

:

CDialog(CELS_RO_AICDlg:

IDD,pParent)

//{{AFX_DATA_INIT(CELS_RO_AICDlg)

m_dwnVAR=0.1;

m_dwnMEAN=0.0;

m_nwnLEN=600;

m_nmVALn=10;

m_nmLOC=103;

m_nmLEN=1023;

//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32

m_hIcon=AfxGetApp()->

LoadIcon(IDR_MAINFRAME);

voidCELS_RO_AICDlg:

//{{AFX_DATA_MAP(CELS_RO_AICDlg)

DDX_Control(pDX,IDC_EDIT_mLOC,m_CEdit_MLOC);

DDX_Control(pDX,IDC_SPIN_MLOC,m_ctrMLOC);

DDX_Text(pDX,IDC_EDIT_wnVAR,m_dwnVAR);

DDX_Text(pDX,IDC_EDIT_wnMEAN,m_dwnMEAN);

DDX_Text(pDX,IDC_EDIT_wnLEN,m_nwnLEN);

DDX_Text(pDX,IDC_EDIT_mVALn,m_nmVALn);

DDX_Text(pDX,IDC_EDIT_mLOC,m_nmLOC);

DDX_Text(pDX,IDC_EDIT_mLEN,m_nmLEN);

DDX_Control(pDX,IDC_STATIC_IDRefTEXT,m_ctrStaticIDRefText);

DDX_Control(pDX,IDC_STATIC_ErrTEXT,m_ctrStaticErrText);

DDX_Control(pDX,IDC_STATIC_GRAPH,m_ctrStaticGraph);

DDX_Control(pDX,IDC_STATIC_RefTEXT,m_ctrStaticRefText);

BEGIN_MESSAGE_MAP(CELS_RO_AICDlg,CDialog)

//{{AFX_MSG_MAP(CELS_RO_AICDlg)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

ON_BN_CLICKED(IDC_BUTTON_whitenoiseMAKE,OnBUTTONwhitenoiseMAKE)

ON_BN_CLICKED(IDC_BUTTON_mSerialMAKE,OnBUTTONmSerialMAKE)

ON_BN_CLICKED(IDC_BUTTON_ELS_RO_AIC,OnButtonElsRoAic)

ON_EN_CHANGE(IDC_EDIT_mVALn,OnChangeEDITmVALn)

ON_WM_DESTROY()

ON_BN_CLICKED(IDC_RADIO_MODEL1,OnRadioModel1)

ON_BN_CLICKED(IDC_RADIO_MODEL2,OnRadioModel2)

ON_WM_LBUTTONDBLCLK()

//CELS_RO_AICDlgmessagehandlers

BOOLCELS_RO_AICDlg:

OnInitDialog()

OnInitDialog();

//Add"

About..."

menuitemtosystemmenu.

//IDM_ABOUTBOXmustbeinthesystemcommandrange.

ASSERT((IDM_ABOUTBOX&

0xFFF0)==IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX<

0xF000);

CMenu*pSysMenu=GetSystemMenu(FALSE);

if(pSysMenu!

=NULL)

{

CStringstrAboutMenu;

strAboutMenu.LoadString(IDS_ABOUTBOX);

if(!

strAboutMenu.IsEmpty())

{

pSysMenu->

AppendMenu(MF_SEPARATOR);

AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);

}

}

//Settheiconforthisdialog.Theframeworkdoesthisautomatically

//whentheapplication'

smainwindowisnotadialog

SetIcon(m_hIcon,TRUE);

//Setbigicon

SetIcon(m_hIcon,FALSE);

//Setsmallicon

//TODO:

Addextrainitializationhere

m_ctrMLOC.SetBuddy(&

m_CEdit_MLOC);

m_ctrMLOC.SetRange(0,m_nmLEN-m_nwnLEN);

m_tempInt=NULL;

CButton*pButton=(CButton*)this->

GetDlgItem(IDC_RADIO_MODEL1);

pButton->

SetCheck

(1);

model=TRUE;

ZZZ=NULL;

returnTRUE;

//returnTRUEunlessyousetthefocustoacontrol

OnSysCommand(UINTnID,LPARAMlParam)

if((nID&

0xFFF0)==IDM_ABOUTBOX)

CAboutDlgdlgAbout;

dlgAbout.DoModal();

else

CDialog:

OnSysCommand(nID,lParam);

//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow

//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,

//thisisautomaticallydoneforyoubytheframework.

OnPaint()

if(IsIconic())

CPaintDCdc(this);

//devicecontextforpainting

SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);

//Centericoninclientrectangle

intcxIcon=GetSystemMetrics(SM_CXICON);

intcyIcon=GetSystemMetrics(SM_CYICON);

CRectrect;

GetClientRect(&

rect);

intx=(rect.Width()-cxIcon+1)/2;

inty=(rect.Height()-cyIcon+1)/2;

//Drawtheicon

dc.DrawIcon(x,y,m_hIcon);

OnPaint();

//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags

//theminimizedwindow.

HCURSORCELS_RO_AICDlg:

OnQueryDragIcon()

return(HCURSOR)m_hIcon;

OnBUTTONwhitenoiseMAKE()

Addyourcontrolnotificationhandlercodehere

//FILE*fp1;

FILE*fp2;

intN=m_nwnLEN+1;

inti;

double*inta1,*inta2;

double*x1,*x2,*y1,*y2;

inta1=(double*)malloc(N*sizeof(double));

inta2=(double*)malloc(N*sizeof(double));

x1=(double*)malloc((N+1)*sizeof(double));

x2=(double*)malloc((N+1)*sizeof(double));

y1=(double*)malloc(N*sizeof(double));

y2=(double*)malloc(N*sizeof(double));

x1[0]=11.0;

x2[0]=13.0;

junyun(N-1,x2,y2);

junyun(N-1,x1,y1);

if((fp2=fopen("

WhiteNoise2.txt"

"

w"

))==NULL)

{

MessageBox("

cannotopenthefile:

WhiteNoise2.txt\n"

);

return;

for(i=0;

i<

N-1;

i++)

inta1[i]=sqrt(-2*log(y1[i]))*cos(2*PAI*y2[i])*sqrt(m_dwnVAR)+m_dwnMEAN;

inta2[i]=sqrt(-2*log(y1[i]))*sin(2*PAI*y2[i])*sqrt(m_dwnVAR)+m_dwnMEAN;

if(inta2[i]>

0)fprintf(fp2,"

%3.12f"

inta2[i]);

elsefprintf(fp2,"

%3.12f"

if(((i+1)%10)==0)fprintf(fp2,"

\n"

fclose(fp2);

free(inta1);

free(inta2);

free(x1);

free(x2);

free(y1);

free(y2);

return;

junyun(intn,doublex[],doubley[])

inti,b;

unsignedlongc;

c=4294967;

for(i=1;

=n+1;

b=(int)(A*x[i-1])/c;

x[i]=(A*x[i-1])-b*c;

y[i-1]=x[i-1]/c;

OnBUTTONmSerialMAKE()

UpdateData(TRUE);

FILE*fp;

inti,j;

intm_nAmpMserial=1;

m_nmLEN=(int)pow(2,m_nmVALn)-1;

UpdateData(FALSE);

int*yita,*u;

u=(int*)malloc(m_nmLEN*sizeof(int));

yita=(int*)malloc(m_nmLEN*sizeof(int));

if((fp=fopen("

MSerials.txt"

MSerials.txt\n"

j=0;

for(i=0;

m_nmVALn;

yita[i]=1;

u[i]=yita[i]*m_nAmpMserial;

fprintf(fp,"

%3d"

u[i]);

j++;

for(i=m_nmVALn;

m_nmLEN;

switch(m_nmVALn)

case2:

yita[i]=yita[i-m_nmVALn]^yita[i-1];

br

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 其它课程

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1