📄 d13r6b.cpp
字号:
#include "iostream.h"
#include "math.h"
#include "stdlib.h"
void main()
{
//program d13r6b
//driver for routine tptest
//Compare two correlated distributions vs. two
//uncorrelated distributions
int i,j,npts = 500, nshft = 10;
double eps = 0.01;
double anoise = 0.3;
double data1[501], data2[501], data3[501];
long idum = -5;
cout<<endl;
cout<<" Correlated: Uncorrelated:"<<endl;
cout<<" shift t probability t probability"<<endl;
double offset = (nshft / 2) * eps;
for (j = 1; j<=npts; j++)
{
double gauss = gasdev(idum);
data1[j] = gauss;
data2[j] = gauss + anoise * gasdev(idum);
data3[j] = gasdev(idum) + anoise * gasdev(idum);
}
double ave1,ave2,ave3,var1,var2,var3;
avevar(data1, npts, ave1, var1);
avevar(data2, npts, ave2, var2);
avevar(data3, npts, ave3, var3);
for (j = 1; j<=npts; j++)
{
data1[j] = data1[j] - ave1 + offset;
data2[j] = data2[j] - ave2;
data3[j] = data3[j] - ave3;
}
double t1,t2,prob1,prob2;
cout.setf(ios::fixed|ios::right);
cout.precision(4);
for (i = 1; i<=nshft + 1; i++)
{
double shift = i * eps;
for (j = 1; j<=npts; j++)
{
data2[j] = data2[j] + eps;
data3[j] = data3[j] + eps;
}
tptest(data1, data2, npts, t1, prob1);
tptest(data1, data3, npts, t2, prob2);
cout.width(10); cout<<shift;
cout.width(10); cout<<t1;
cout.width(10); cout<<prob1;
cout.width(10); cout<<t2;
cout.width(10); cout<<prob2<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -