#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>

int main(void)
{
	
	FILE *input_file;		//establish a "pointer" to an input file

	int num_data_points;;	//intialize num_data_points
	input_file = fopen("x_data.txt","r");	//open time_tempf.txt for reading
	fscanf(input_file, "%i", &num_data_points);	//read the number of time_temp combos

	double x[num_data_points];	//Set up size and type of array

	int i;
	//Read in x vals
	double temp = 0.0;
	for(i = 0; i < num_data_points; i++)
	{
		fscanf(input_file, "%lf", &temp);
		x[i] = temp;
	}
	
	//Calc. Mean	
	double sum = 0;
	for(i=0; i<num_data_points; i++)
	{
		sum+=x[i];
	}
	double mean = sum/(double)num_data_points;
	
	//Calc std. dev.
	sum = 0;
	for(i=0; i<num_data_points; i++)
	{
		sum+=pow((mean - x[i]), 2);
	}

	double stddev = pow((sum/(num_data_points - 1)),0.5);

	printf("Mean of data set = %.5e \nStddev of data set = %.1e\n", mean, stddev);

	return 0;
}
	

