📄 d13r7.cpp
字号:
#include "iostream.h"
#include "math.h"
#include "stdlib.h"
void main()
{
//program d13r7
//driver for routine ftest
int npts = 1000, nval = 10;
int i,j,mpts = 500;
double f,prob,var,factor,eps = 0.01;
double data1[1001], data2[501], data3[501];
//generate two gaussian distributions with
//different variances
long idum = -13;
for (j = 1; j<=npts; j++)
{
data1[j] = gasdev(idum);
}
for (j = 1; j<=mpts; j++)
{
data2[j] = gasdev(idum);
}
cout<<endl;
cout<<"Variance 1 = "<<1.0;
cout<<endl;
cout<<" Variance 2 Ratio Probability"<<endl;
cout.setf(ios::fixed|ios::right);
cout.precision(4);
for (i = 1; i<=nval + 1; i++)
{
var = 1.0 + (i - 1) * eps;
factor = sqrt(var);
for (j = 1; j<=mpts; j++)
{
data3[j] = factor * data2[j];
}
ftest(data1, npts, data3, mpts, f, prob);
cout.width(12);
cout<<var;
cout.width(12);
cout<<f;
cout.width(12);
cout<<prob<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -