/** * \file Histogram.cpp \brief simple histogram class * * Copyright 2007-2010 IMP Inventors. All rights reserved. */ #include #include IMPSTATISTICS_BEGIN_NAMESPACE Histogram::Histogram(double start, double end, unsigned int num_bins) { start_=start; end_=end; interval_size_ = (end-start)/num_bins; freq_.insert(freq_.end(),num_bins,0); } void Histogram::add(double x) { IMP_INTERNAL_CHECK(!(xend_),"the value being added to the "<< "histogram "<((x-start_)/interval_size_)); freq_[i]++; } unsigned int Histogram::get_total_count() const { return std::accumulate(freq_.begin(),freq_.end(),0); } void Histogram::show(std::ostream& out) const { out<<"histogram for range:["<1.)), "The input number is not a percentage\n"); float stop_count = get_total_count()*percentage; int partial_count=0; for(unsigned int i=0;i stop_count) { return start_+i*interval_size_; } } return end_; } IMPSTATISTICS_END_NAMESPACE