?? d9r1.cpp
字號:
#include "iostream.h"
#include "stdlib.h"
#include "math.h"
void main()
{
//program d9r1
//driver for routine fit
int i,mwt,npt = 100;
double spread = 0.5;
double x[101], y[101], sig[101];
double a, b, siga, sigb, chi2, q;
long idum = -117;
for (i = 1; i<=npt; i++)
{
x[i] = 0.1 * i;
y[i] = -2.0 * x[i] + 1.0 + spread * gasdev(idum);
sig[i] = spread;
}
for (mwt = 0; mwt<=1; mwt++)
{
fit(x, y, npt, sig, mwt, a, b, siga, sigb, chi2, q);
if (mwt == 0)
{
cout<<endl;
cout<<"Ignoring standard deviation"<<endl;
cout<<endl;
}
else
{
cout<<endl;
cout<<"Including standard deviation"<<endl;
cout<<endl;
}
cout<<"a = "<<a<<" ";
cout<<"Uncertainty: "<<siga<<endl;
cout<<endl;
cout<<"b = "<<b<<" ";
cout<<"Uncertainty: "<<sigb<<endl;
cout<<endl;
cout<<"Chi-squared: "<<chi2<<endl;
cout<<endl;
cout<<"Goodness-of-fit: "<<q<<endl;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -