//#######################################################################
// A C++ program to provide examples of use of methods
// in the deSolve class to numerically
// solve an SIR model
//
// Author: Sherry Towers
//         smtowers@asu.edu
// Created: Mar 22nd, 2013
//
// Copyright Sherry Towers, 2013
//
// This program is not guaranteed to be free of bugs and/or errors.
//
// This program can be freely used and shared, as long as the author information
// and copyright in the header remains intact.
//#######################################################################
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <iostream>
#include "UsefulUtils.h"

//################################################################################
//################################################################################
using namespace std;
int main(int argc, char **argv){
  //int iranda = unsigned(time(0)); // seconds since Jan 1st, 1970
  //srand(iranda); // set the random seed

  UsefulUtils myutil;

  //##############################################################################
  // randomly select 5 numbers out of 100
  //##############################################################################
  cout << "\n\n\n";
  vector<double> vresult;
  myutil.RandomSample(15,100,vresult);
  cout << "Fifteen random numbers selected from 1 to 100 without replacement:\n";
  for (int i=0;i<vresult.size();i++){cout << vresult[i] << endl;}
  cout << "The maximum value of the vector " << myutil.Max(vresult) <<  endl;
  cout << "The minimum value of the vector " << myutil.Min(vresult) <<  endl;
  cout << "The index of the maximum value of the vector " << myutil.WhichMax(vresult) <<  endl;
  cout << "The index of the minimum value of the vector " << myutil.WhichMin(vresult) <<  endl;
  cout << "The mean  of the vector " << myutil.Mean(vresult) <<  endl;
  cout << "The stdev of the vector " << myutil.SD(vresult) <<  endl;
  cout << "The variance of the vector " << myutil.Variance(vresult) <<  endl;
  cout << "The sum of the vector " << myutil.Sum(vresult) <<  endl;
  double distance;
  cout << "The index of the element that is closest to 50 " << myutil.ClosestIndex(50.0,vresult,distance) << endl;
 
  cout << "The cumulative sum of the vector:\n";
  vector<double> csum = myutil.CumulativeSum(vresult);
  for (int i=0;i<csum.size();i++){cout << csum[i] << endl;}
  cout << "The sum in a moving window of length 3:\n";
  vector<double> rsum = myutil.RunningSum(3,0,vresult);
  for (int i=0;i<rsum.size();i++){cout << rsum[i] << endl;}

  //##############################################################################
  //##############################################################################
  cout << "\n\n\n";
  cout << "A random number from Pois(5) " << myutil.RandomPoisson(5.0) << endl;
  cout << "A random number from Exp(0.1) " << myutil.RandomExponential(0.1) << endl;
  cout << "A random number from Unif(10,100) " << myutil.RandomUniform(10.0,100.0) << endl;
  cout << "A random number from Normal(2,10) " << myutil.RandomNormal(2.0,10.0) << endl;
  cout << "\n\n\n";

  return 0;

} // end program

