#ifndef ReHist1d_HH #define ReHist1d_HH ////////////////////////////////////////////////////////////////////////// //! file="amma/Statist/Hist/ReHist1d.hh" //! lib=Mstat //! userlevel=Normal //! author="Radek Marik" //! docentry="Statistics.Histograms" //! date="06/08/95" //! rcsid="$Id: ReHist1d.hh,v 1.10 1999/12/02 11:24:00 ees1cg Exp $" #include "amma/StdType.hh" #include "amma/IntArr1d.hh" #include "amma/MeanCo1d.hh" class ostream; class istream; struct HistogramMode1dT { IndexT maxIndex; IndexRangeC range; RealT maxMode; RealT minValue, maxValue; RealT relativeSize; // peak_vote_number/ histogram_vote_number MeanCovariance1dC mc; }; ostream & operator<<(ostream & s, const HistogramMode1dT & mode); // Saves the 'mode' into the output stream. //====================================================================== //======== HistModes1dC ================================================ //====================================================================== class HistModes1dC: public Array1dC { public: HistModes1dC(SizeT num); // Creates the number 'num' of non-inicialized modes of 1d histogram. HistModes1dC(const HistModes1dC & modes); // Copy constructor. IndexT Mode(const RealT value) const; // Returns the index of the mode which the 'value' belongs to. // The first mode is returned for values smaller than the maximum value // of the first mode. The last mode is returned for value greater // or equal than the minimum value of the last mode. }; ostream & operator<<(ostream & s, const HistModes1dC & modes); // Saves the 'modes' into the output stream. //====================================================================== //======== RealHistogram1dC ============================================ //====================================================================== //: RealHistogram1dC represents a histogram of real scalar values. // It is possible set up its resolution, eg. the size of bins. // The histogram works on the interval are ignored. // Special operators. // ------------------ HistModes1dC Modes(RealT minModeDistance = 1.0) const; // Returns the list of modes of the histogram. private: RealT minValue; // minimum accepted value RealT maxValue; // a value just greater than maximum accepted value RealT delta; // the size of bins friend ostream & operator<<(ostream & s, const RealHistogram1dC & arr); }; ostream & operator<<(ostream & s, const RealHistogram1dC & arr); inline RealHistogram1dC::RealHistogram1dC(RealT min, RealT max, RealT resolution) //================================================== : IntArray1dC((SizeT)((max-min)/resolution)), minValue(min), maxValue(max), delta(resolution) { SetZero(); } inline RealHistogram1dC::RealHistogram1dC(const RealHistogram1dC & vv) //============================================================= : IntArray1dC(vv), minValue(vv.minValue), maxValue(vv.maxValue), delta(vv.delta) {} inline RealT RealHistogram1dC::StartX(const IndexT i) const //============================================ { return i * delta + minValue; } inline RealT RealHistogram1dC::MidX(const IndexT i) const //========================================== { return i * delta + minValue + delta/2; } inline void RealHistogram1dC::Vote(RealT value) //================================= { (*this)[(IndexT)(IntT)((value-minValue)/delta)]++; } inline void RealHistogram1dC::CheckedVote(RealT value) //======================================== { if (value >= minValue && value < maxValue) Vote(value); } #endif // End of the include file ReHist1d.hh