//false_mean - simple progam comparing results from mean and false mean // Jim Crumley 20130225 // #include using namespace std; const int size = 5; float naive_mean (float y[], int num); float mean2 (float f_mean, float y[], int num); int main () { float wavenumbers[size] = {12683.7821, 12685.9842, 12686.2439, 12685.789, 12686.1323}; float false_mean =12680.0; //float w_ave1, w_ave2; cout.precision(9); cout << "Mean\n Calculated naively: "<< naive_mean(wavenumbers, size); cout << "\nCalculated using a false mean of "<< false_mean <<": "; cout << mean2(false_mean, wavenumbers, size)<< " \n"; //cout << mean2(false_mean, wavenumbers, size) + false_mean<< "\n"; return 0; } // Calculate mean directly float naive_mean (float y[], int num){ float sum = 0; for (int i=0; i < num; i++) sum = sum + y[i]; return sum/num; } //calculate mean using false mean to preserve precision float mean2 (float f_mean, float y[], int num) { float sum = 0, f_ave; //cout <<"\n\n"; for (int i=0; i < num; i++) { sum = sum + (y[i]- f_mean); // cout << i << " " << y[i] <<" "<