P276 9.14

#include <iostream>
using namespace std;
template<class numtype>
class Compare
{
	public:
		Compare(numtype a,numtype b)
		{x=a;y=b;}
		numtype max()
		{return(x>y)?x:y;}
		numtype min()
		{return(x<y)?x:y;}
		private:
			numtype x,y;
};
int main()
{
	Compare<int>cmp1(3,7);
	cout<<cmp1.max()<<"is the Maximum of two integer numbers."<<endl;
	cout<<cmp1.min()<<"is the Minimum of two integer numbers."<<endl<<endl;
	Compare<float>cmp2(45.78,93.6);
	cout<<cmp2.max()<<"is the Maximum of two float numbers"<<endl;
	cout<<cmp2.min()<<"is the Minimum of two float numbers"<<endl<<endl;
	Compare<char>cmp3('a','A');
	cout<<cmp3.max()<<"is the Maximum of two characters."<<endl;
	cout<<cmp3.min()<<"is the Minimum of two characters."<<endl<<endl;
	return 0;
}

对以下多元回归分析MATLAB代码进行分析,残差分析,x=[15037 18.8 1366 17001 18 1519 18718 3.1 1644 21826 3.4 1893 26937 6.4 2311 35260 14.7 2998 48108 24.1 4044 59811 17.1 5046 70142 8.3 5846 78061 2.8 6420 83024 -0.8 6796 88479 -1.4 7159 98000 0.4 7858 108068 0.7 8622 119096 -0.8 9398 135174 1.2 10542 159587 3.9 12336 184089 1.8 14040 213132 1.5 16024 235367 1.7 17535 277654 1.9 19264]; y=[15.73 15.04 14.39 12.98 11.6 11.45 11.21 10.55 10.42 10.06 9.14 8.18 7.58 6.95 6.45 6.01 5.87 5.89 5.38 5.24 5.45]; [m,n]=size(x); X=[ones(m,1) x]; [m1,n1]=size(X); [m2,n2]=size(y); for i=1:n2 %b 为参数,bint 回归系数的区间估计,r 为残差, %rint 为置信区间,stats 用于回归模型检验 [b(:,i),bint,r,rint,stats(i,:)]=regress(y(:,i),X); [mm,nn]=size(b); for jj=1:m1 temp=0; for ii=1:mm yy(jj,i)=temp+b(ii,i)*X(jj,ii); temp=yy(jj,i); end end xiangdui_wucha(1,i)=abs(abs(y(1,i))-abs(yy(1,i)))/abs(y(1,i)); if n2~=1 subplot(2,n2/2,i); rcoplot(r,rint)%残差分析,作出残差及其置信区间 else rcoplot(r,rint)%残差分析,作出残差及其置信区间 end end disp('参数'); b %参数计算 disp('预测结果'); yy %检验回归模型:相关系数 r^2=stats(1,:)越接近 1 回归方程越显著 %F=stats(2,:)值越大回归方程越显著、p=stats(3,:)<0.01 时回归模型成立 disp('回归模型检验:'); format long stats for i=1:n2 if (stats(i,4)<0.01)&(stats(i,1)>0.6) disp('回归方程显著-------模型成立'); end end format short disp('相对误差'); xiangdui_wucha%第一行原始值与预测值的相对误差
06-03
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值