C语言误差处理(平均数残差)
#include
#include
#include
#include
double d[100];double x1=0.0,x2=0.0,x3=0.0,average=0.0;
double T[]={63.66,9.92,5.84,4.60,4.03,3.71,3.50,3.36,3.25,3.17,3.11,3.05,3.01,2.98,2.95,2.92,2.90,2.88,2.86,2.85,2.83, 2.82,2.81,2.80,2.79,2.78,2.77,2.76,2.76,2.75,2.70,2.68,2.66,2.65,2.64,2.63,2.63,2.58};
double average_fun(double datas[],int datas_num)
{
int k=0;
for(k=0;k
{
average+=datas[k];
}
average/=datas_num;
return average;
}
double surplus(int num,double a[],double x)
{
int i,j;double c[100],w;
for(i=0;i
{
c[i]=a[i]-x;
d[i]=c[i];
}
printf("求得的残余误差为:\n ");
for(j=0;j
printf("%f ",d[j]);
for(i=0;i
{
w+=d[i];
}
return(w);
}
void check(int num,double w)
{
double A;
if(num%2==0)
{
if(w>num/2.0*A)
{
printf("该算术平均值不正确!\n");
}
else printf("该算术平均值正确!\n");
}
else
{
if(w>(num/2.0-0.5)*A)
{
printf("该算术平均值不正确!\n");
}
else printf("该算术平均值正确!\n");
}
}
judge1(int num)
{
int t,j;double m=0.0,n=0.0,z=0.0;
if(num%2==0)
{
t=num/2;
for(j=0;j
m+=d[j];
for(j=t;j
n+=d[j];
z=m-n;
}
else
{
t=(num+1)/2;
for(j=0;j
m+=d[j];
for(j=t;j
n+=d[j];
z=m-n;printf("%lf",z);
}
if(z<=0.002)
printf("无根据怀疑此组存在系统误差\n");
else
printf("怀疑此组存在系统误差\n");
}
std(int num,double data[])
{
double m=0.0;int k;
for(k=0;k
{
m+=data[k]*data[k];
}
x1=sqrt(m/(num-1));
x2=x1/(sqrt(num));
}
void judge2(int w)
{
int i;
for(i=0;i
{
if(d[i]<3*x1)
printf("该数据存在粗大误差\n");
else
printf("该数据不存在粗大误差\n");
}
}
limit(int num)
{
double t=0.0;
t=T[num-1];
x3=t*x2;
}
bear(int datas_num,double datas[])
{
double y=0.0,k=0.0;int i;
for(i=0;i
{
k+=datas[i];
}
k/=datas_num;
y=k+x3;
printf("结果为:");
printf("%lf",y);
}
void main()
{
int num;
int i;
double a[100];
double x=0.0,w=0.0;
printf("输入实验组数:");
scanf("%d",&num);
printf("输入测得的数据:");
for(i=0;i
scanf("%lf",&a