/usr/include/ns3.26/ns3/histogram.h is in libns3-dev 3.26+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2009 INESC Porto
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: Pedro Fortuna <pedro.fortuna@inescporto.pt> <pedro.fortuna@gmail.com>
//
#ifndef NS3_HISTOGRAM_H
#define NS3_HISTOGRAM_H
#include <vector>
#include <stdint.h>
#include <ostream>
namespace ns3 {
/**
* \brief Class used to store data and make an histogram of the data frequency.
*
* Data are grouped in "bins", i.e., intervals. Each value is assigned to the
* bin according to the following formula: floor(value/binWidth).
* Hence, bin \a i groups the data from [i*binWidth, (i+1)binWidth).
*
* This class only handles \a positive bins, i.e., it does \a not handles negative data.
*
* \todo Add support for negative data.
*
* \todo Add method(s) to estimate parameters from the histogram,
* see http://www.dspguide.com/ch2/4.htm
*
*/
class Histogram
{
public:
// --- basic methods ---
/**
* \brief Constructor
* \param binWidth width of the histogram "bin".
*/
Histogram (double binWidth);
Histogram ();
// Methods for Getting the Histogram Results
/**
* \brief Returns the number of bins in the histogram.
* \return the number of bins in the histogram
*/
uint32_t GetNBins () const;
/**
* \brief Returns the bin start, i.e., index*binWidth
* \param index the bin index
* \return the bin start
*/
double GetBinStart (uint32_t index);
/**
* \brief Returns the bin end, i.e., (index+1)*binWidth
* \param index the bin index
* \return the bin start
*/
double GetBinEnd (uint32_t index);
/**
* \brief Returns the bin width.
*
* Note that all the bins have the same width.
*
* \param index the bin index
* \return the bin width
*/
double GetBinWidth (uint32_t index) const;
/**
* \brief Set the bin width.
*
* Note that you can change the bin width only if the histogram is empty.
*
* \param binWidth the bin width
*/
void SetDefaultBinWidth (double binWidth);
/**
* \brief Get the number of data added to the bin.
* \param index the bin index
* \return the number of data added to the bin
*/
uint32_t GetBinCount (uint32_t index);
// Method for adding values
/**
* \brief Add a value to the histogram
* \param value the value to add
*/
void AddValue (double value);
/**
* \brief Serializes the results to an std::ostream in XML format.
* \param os the output stream
* \param indent number of spaces to use as base indentation level
* \param elementName name of the element to serialize.
*/
void SerializeToXmlStream (std::ostream &os, int indent, std::string elementName) const;
private:
std::vector<uint32_t> m_histogram; //!< Histogram data
double m_binWidth; //!< Bin width
};
} // namespace ns3
#endif /* NS3_HISTOGRAM_H */
|