#include "../ex1A_mean_values/means.h"
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;


int main(int argc, char **argv)
{
    // read vector from file
    vector<int> data_vector = {};

    ifstream input_stream("data_1.txt"); 

    int line;
    while(input_stream >> line)
    {
        data_vector.push_back(line);
    }
    data_vector.shrink_to_fit();


    // calculate minimum and maximum
    vector<int>::iterator min_it = min_element(data_vector.begin(), data_vector.end());
    vector<int>::iterator max_it = max_element(data_vector.begin(), data_vector.end());

    // calculate arithmetic mean, geometric mean and harmonic mean
    double am, gm, hm;
    calculate_means(data_vector, am, gm, hm);


    // calculate standard deviation
    double sd = 0.;
    int n = data_vector.size();
    for (int i = 0; i < n; ++i)
    {
        sd += pow(data_vector[i] - am, 2);
    }
    sd = sqrt(sd/n);


    // print results
    cout << "minimum: " << *min_it << endl;
    cout << "maximum: " << *max_it << endl;
    cout << "arithmetic mean: " << am << endl;
    cout << "geometric mean: " << gm << endl;
    cout << "harmonic mean: " << hm << endl;
    cout << "standard deviation: " << sd << endl;

    return 0;
}
