Using sets of data are variance, design function evaluation given integer number N of mean square error. If the average number N A [] is referred to as Avg, average variance is calculated as: √ [(A 1 -Avg) 2 + (A 2 -A

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; 
	
}
Published 123 original articles · won praise 8 · views 20000 +

Guess you like

Origin blog.csdn.net/Du798566/article/details/104762690