Commit c4a60da3 authored by david's avatar david
Browse files

Ajout analyzer.cpp

parent 20746e66
#include "analyzer.hpp"
#include <fstream>
void Analyzer::append(const double & x){
cumulative_cost.push_back( (cumulative_cost.size()) ? cumulative_cost.back()+x : x);
cumulative_square += x*x;
double Analyzer::get_average_cost(){
throw std::runtime_error("List is empty");
return cumulative_cost.back()/cumulative_cost.size();
double Analyzer::get_variance(){
double mean, mean_square;
mean = get_average_cost();
mean_square = mean * mean;
return cumulative_square - mean_square;
void Analyzer::save_values(const std::string & path){
std::ofstream f;
size_t i;;
for (i = 0; i < cost.size(); ++i)
f<<i<<" "<<<<" "<<get_amortized_cost(i)<<std::endl;
void Analyzer::plot_values(){
size_t i;
for (i = 0; i < cost.size(); ++i)
std::cout<<i<<" "<<<<" "<<get_amortized_cost(i)<<std::endl;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment