Using sets of data mean square
design function evaluations given integer number N of mean square error. If the average number N A [] is referred to as Avg, average variance is calculated as follows: each - and the average value of the square of the square root averaging.
Input format:
input is first given a positive integer N (≦ 10 in the first row
4
), followed by a line of N gives a positive integer. All numbers no more than 1,000 peer-digit separated by a space.
Output Format:
Output number N of mean square error which, after fixation in claim 5 decimal accuracy of the output.
Input Sample 1:
10
. 6. 7 1. 4. 3. 11. 9 2. 8. 5
Output Sample 1:
3.03974
Input 2 Sample:
1
2
Output Sample 2:
0.00000
# include<stdio.h>
# include<math.h>
int main()
{
int A[10000],m,i,j,sum=0;
double x,y1=0,y2=0;
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%d",&A[i]);
sum+=A[i];
}
x=sum*1.0/m;
for(i=0;i<m;i++)
{
y1+=(A[i]-x)*(A[i]-x);
}
y2=sqrt(y1/m);
printf("%0.5lf",y2);
return 0;
}