move average.h from tools to stats module
authorTom Henderson <tomh@tomh.org>
Tue, 18 Jun 2013 13:42:57 -0700
changeset 9843 ea6ed35dd7b2
parent 9842 b03e518b3336
child 9844 caeedc5acd19
move average.h from tools to stats module
src/applications/wscript
src/core/examples/wscript
src/flow-monitor/wscript
src/netanim/examples/uan-animation.cc
src/netanim/examples/uan-animation.h
src/netanim/examples/wscript
src/olsr/wscript
src/propagation/examples/wscript
src/stats/model/average.h
src/stats/test/average-test-suite.cc
src/stats/wscript
src/test/wscript
src/tools/model/average.h
src/tools/test/average-test-suite.cc
src/tools/wscript
--- a/src/applications/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/applications/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -1,7 +1,7 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
 def build(bld):
-    module = bld.create_ns3_module('applications', ['internet', 'config-store', 'tools'])
+    module = bld.create_ns3_module('applications', ['internet', 'config-store','stats'])
     module.source = [
         'model/bulk-send-application.cc',
         'model/onoff-application.cc',
--- a/src/core/examples/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/core/examples/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -15,10 +15,10 @@
     obj = bld.create_ns3_program('main-ptr', ['core'] )
     obj.source = 'main-ptr.cc'
 
-    obj = bld.create_ns3_program('main-random-variable', ['core', 'config-store', 'tools'])
+    obj = bld.create_ns3_program('main-random-variable', ['core', 'config-store','stats'])
     obj.source = 'main-random-variable.cc'
 
-    obj = bld.create_ns3_program('main-random-variable-stream', ['core', 'config-store', 'tools'])
+    obj = bld.create_ns3_program('main-random-variable-stream', ['core', 'config-store','stats'])
     obj.source = 'main-random-variable-stream.cc'
 
     obj = bld.create_ns3_program('sample-random-variable',
--- a/src/flow-monitor/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/flow-monitor/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -1,7 +1,7 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
 def build(bld):
-    obj = bld.create_ns3_module('flow-monitor', ['internet', 'config-store', 'tools'])
+    obj = bld.create_ns3_module('flow-monitor', ['internet', 'config-store'])
     obj.source = ["model/%s" % s for s in [
        'flow-monitor.cc',
        'flow-classifier.cc',
--- a/src/netanim/examples/uan-animation.cc	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/netanim/examples/uan-animation.cc	Tue Jun 18 13:42:57 2013 -0700
@@ -41,7 +41,6 @@
 #include "ns3/network-module.h"
 #include "ns3/netanim-module.h"
 #include "ns3/mobility-module.h"
-#include "ns3/tools-module.h"
 #include "ns3/applications-module.h"
 
 #include <fstream>
--- a/src/netanim/examples/uan-animation.h	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/netanim/examples/uan-animation.h	Tue Jun 18 13:42:57 2013 -0700
@@ -22,7 +22,6 @@
 #define UAN_CW_EXAMPLE_H
 
 #include "ns3/network-module.h"
-#include "ns3/tools-module.h"
 #include "ns3/uan-module.h"
 
 using namespace ns3;
--- a/src/netanim/examples/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/netanim/examples/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -18,7 +18,7 @@
     obj.source = 'wireless-animation.cc'
     
     obj = bld.create_ns3_program('uan-animation',
-                                 ['netanim', 'internet', 'mobility', 'tools', 'applications', 'uan'])
+                                 ['netanim', 'internet', 'mobility', 'applications', 'uan'])
     obj.source = 'uan-animation.cc'
 
     obj = bld.create_ns3_program('dynamic_linknode',
--- a/src/olsr/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/olsr/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -1,7 +1,7 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
 def build(bld):
-    module = bld.create_ns3_module('olsr', ['internet', 'config-store', 'tools', 'point-to-point', 'wifi', 'mobility', 'applications', 'csma'])
+    module = bld.create_ns3_module('olsr', ['internet', 'config-store', 'point-to-point', 'wifi', 'mobility', 'applications', 'csma'])
     module.includes = '.'
     module.source = [
         'model/olsr-header.cc',
--- a/src/propagation/examples/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/propagation/examples/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -5,7 +5,7 @@
         return;
 
     obj = bld.create_ns3_program('main-propagation-loss',
-                                 ['core', 'mobility', 'config-store', 'tools', 'propagation'])
+                                 ['core', 'mobility', 'config-store', 'stats', 'propagation'])
     obj.source = 'main-propagation-loss.cc'
 
     obj = bld.create_ns3_program('jakes-propagation-model-example',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/stats/model/average.h	Tue Jun 18 13:42:57 2013 -0700
@@ -0,0 +1,125 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 IITP RAS
+ *
+ * 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
+ *
+ * Authors: Pavel Boyko <boyko@iitp.ru>
+ * Corrections and extensions: Timo Bingmann <tbns@idlebox.net>
+ */
+
+#ifndef AVERAGE_H
+#define AVERAGE_H
+#include <cmath>
+#include <ostream>
+#include <limits>
+#include <stdint.h>
+#include "ns3/basic-data-calculators.h"
+
+namespace ns3 {
+
+/**
+ * \defgroup tools Tools
+ *
+ */
+
+/**
+ * \ingroup tools
+ *
+ * Simple average, min, max and std. deviation calculator
+ *
+ */
+
+template <typename T = double>
+class Average
+{
+public:
+  Average ()
+    : m_size (0), m_min (std::numeric_limits<T>::max ()), m_max (0)
+  {
+  }
+
+  /// Add new sample
+  void Update (T const & x)
+  {
+    // Give the variance calculator the next value.
+    m_varianceCalculator.Update (x);
+
+    m_min = std::min (x, m_min);
+    m_max = std::max (x, m_max);
+    m_size++;
+  }
+  /// Reset statistics
+  void Reset ()
+  {
+    m_varianceCalculator.Reset ();
+
+    m_size = 0;
+    m_min = std::numeric_limits<T>::max ();
+    m_max = 0;
+  }
+
+  ///\name Sample statistics
+  //\{
+  /// Sample size
+  uint32_t Count   () const { return m_size; }
+  /// Minimum
+  T        Min     () const { return m_min; }
+  /// Maximum
+  T        Max     () const { return m_max; }
+  /// Sample average
+  double   Avg     () const { return m_varianceCalculator.getMean ();}
+  /// Estimate of mean, alias to Avg
+  double   Mean    () const { return Avg (); }
+  /// Unbiased estimate of variance
+  double   Var     () const { return m_varianceCalculator.getVariance ();}
+  /// Standard deviation
+  double   Stddev  () const { return std::sqrt (Var ()); }
+  //\}
+
+  /** 
+   * \name Error of the mean estimates
+   *
+   * Note that estimates are valid for 
+   *   - uncorrelated measurements, 
+   *   - normal distribution and
+   *   - large enough sample size.
+   */
+  //\{
+  /// Margin of error of the mean for 90% confidence level 
+  double   Error90 () const { return 1.645 * std::sqrt (Var () / Count ()); }
+  /// Margin of error of the mean for 95% confidence level 
+  double   Error95 () const { return 1.960 * std::sqrt (Var () / Count ()); }
+  /// Margin of error of the mean for 99% confidence level 
+  double   Error99 () const { return 2.576 * std::sqrt (Var () / Count ()); }
+  //\}
+
+private:
+  uint32_t m_size;
+  T      m_min, m_max;
+  MinMaxAvgTotalCalculator<double> m_varianceCalculator;
+};
+
+/// Print avg (err) [min, max]
+template <typename T>
+std::ostream & operator<< (std::ostream & os, Average<T> const & x)
+{
+  if (x.Count () != 0)
+    os << x.Avg () << " (" << x.Stddev () << ") [" << x.Min () << ", " << x.Max () << "]";
+  else
+    os << "NA";  // not available
+  return os;
+}
+}
+#endif /* AVERAGE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/stats/test/average-test-suite.cc	Tue Jun 18 13:42:57 2013 -0700
@@ -0,0 +1,251 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012 University of Washington
+ *
+ * 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: Mitch Watrous (watrous@u.washington.edu)
+ */
+
+#include <cmath>
+
+#include "ns3/test.h"
+#include "ns3/average.h"
+
+using namespace ns3;
+
+const double TOLERANCE = 1e-14;
+
+// ===========================================================================
+// Test case for a single integer.
+// ===========================================================================
+
+class OneIntegerAverageTestCase : public TestCase
+{
+public:
+  OneIntegerAverageTestCase ();
+  virtual ~OneIntegerAverageTestCase ();
+
+private:
+  virtual void DoRun (void);
+};
+
+OneIntegerAverageTestCase::OneIntegerAverageTestCase ()
+  : TestCase ("Average Object Test using One Integer")
+
+{
+}
+
+OneIntegerAverageTestCase::~OneIntegerAverageTestCase ()
+{
+}
+
+void
+OneIntegerAverageTestCase::DoRun (void)
+{
+  Average<int> calculator;
+
+  long count = 1;
+
+  double sum = 0;
+  double sqrSum = 0;
+  double min;
+  double max;
+  double mean;
+  double stddev;
+  double variance;
+
+  // Put all of the values into the calculator.
+  int multiple = 5;
+  int value;
+  for (long i = 0; i < count; i++)
+    {
+      value = multiple * (i + 1);
+
+      calculator.Update (value);
+
+      sum    += value;
+      sqrSum += value * value;
+    }
+
+  // Calculate the expected values for the statistical functions.
+  min = multiple;
+  max = multiple * count;
+  mean = sum / count;
+  variance = 0;
+  stddev = std::sqrt (variance);
+
+  // Test the calculator.
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (),    count,    TOLERANCE, "Count value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Min (),      min,      TOLERANCE, "Min value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Max (),      max,      TOLERANCE, "Max value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Mean (),     mean,     TOLERANCE, "Mean value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Stddev (),   stddev,   TOLERANCE, "Stddev value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Var (), variance, TOLERANCE, "Variance value wrong");
+}
+
+
+// ===========================================================================
+// Test case for five integers.
+// ===========================================================================
+
+class FiveIntegersAverageTestCase : public TestCase
+{
+public:
+  FiveIntegersAverageTestCase ();
+  virtual ~FiveIntegersAverageTestCase ();
+
+private:
+  virtual void DoRun (void);
+};
+
+FiveIntegersAverageTestCase::FiveIntegersAverageTestCase ()
+  : TestCase ("Average Object Test using Five Integers")
+
+{
+}
+
+FiveIntegersAverageTestCase::~FiveIntegersAverageTestCase ()
+{
+}
+
+void
+FiveIntegersAverageTestCase::DoRun (void)
+{
+  Average<int> calculator;
+
+  long count = 5;
+
+  double sum = 0;
+  double sqrSum = 0;
+  double min;
+  double max;
+  double mean;
+  double stddev;
+  double variance;
+
+  // Put all of the values into the calculator.
+  int multiple = 5;
+  int value;
+  for (long i = 0; i < count; i++)
+    {
+      value = multiple * (i + 1);
+
+      calculator.Update (value);
+
+      sum    += value;
+      sqrSum += value * value;
+    }
+
+  // Calculate the expected values for the statistical functions.
+  min = multiple;
+  max = multiple * count;
+  mean = sum / count;
+  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
+  stddev = std::sqrt (variance);
+
+  // Test the calculator.
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (),    count,    TOLERANCE, "Count value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Min (),      min,      TOLERANCE, "Min value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Max (),      max,      TOLERANCE, "Max value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Mean (),     mean,     TOLERANCE, "Mean value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Stddev (),   stddev,   TOLERANCE, "Stddev value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Var (), variance, TOLERANCE, "Variance value wrong");
+}
+
+
+// ===========================================================================
+// Test case for five double values.
+// ===========================================================================
+
+class FiveDoublesAverageTestCase : public TestCase
+{
+public:
+  FiveDoublesAverageTestCase ();
+  virtual ~FiveDoublesAverageTestCase ();
+
+private:
+  virtual void DoRun (void);
+};
+
+FiveDoublesAverageTestCase::FiveDoublesAverageTestCase ()
+  : TestCase ("Average Object Test using Five Double Values")
+
+{
+}
+
+FiveDoublesAverageTestCase::~FiveDoublesAverageTestCase ()
+{
+}
+
+void
+FiveDoublesAverageTestCase::DoRun (void)
+{
+  Average<double> calculator;
+
+  long count = 5;
+
+  double sum = 0;
+  double sqrSum = 0;
+  double min;
+  double max;
+  double mean;
+  double stddev;
+  double variance;
+
+  // Put all of the values into the calculator.
+  double multiple = 3.14;
+  double value;
+  for (long i = 0; i < count; i++)
+    {
+      value = multiple * (i + 1);
+
+      calculator.Update (value);
+
+      sum    += value;
+      sqrSum += value * value;
+    }
+
+  // Calculate the expected values for the statistical functions.
+  min = multiple;
+  max = multiple * count;
+  mean = sum / count;
+  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
+  stddev = std::sqrt (variance);
+
+  // Test the calculator.
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (),    count,    TOLERANCE, "Count value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Min (),      min,      TOLERANCE, "Min value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Max (),      max,      TOLERANCE, "Max value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Mean (),     mean,     TOLERANCE, "Mean value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Stddev (),   stddev,   TOLERANCE, "Stddev value wrong");
+  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Var (), variance, TOLERANCE, "Variance value wrong");
+}
+
+
+class AverageTestSuite : public TestSuite
+{
+public:
+  AverageTestSuite ();
+};
+
+AverageTestSuite::AverageTestSuite ()
+  : TestSuite ("average", UNIT)
+{
+  AddTestCase (new OneIntegerAverageTestCase, TestCase::QUICK);
+  AddTestCase (new FiveIntegersAverageTestCase, TestCase::QUICK);
+  AddTestCase (new FiveDoublesAverageTestCase, TestCase::QUICK);
+}
+
+static AverageTestSuite averageTestSuite;
--- a/src/stats/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/stats/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -26,6 +26,7 @@
     module_test = bld.create_ns3_module_test_library('stats')
     module_test.source = [
         'test/basic-data-calculators-test-suite.cc',
+        'test/average-test-suite.cc',
         ]
 
     headers = bld(features='ns3header')
@@ -39,6 +40,7 @@
         'model/omnet-data-output.h',
         'model/data-collector.h',
         'model/gnuplot.h',
+        'model/average.h',
         'helper/delay-jitter-estimation.h',
         ]
 
--- a/src/test/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/test/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -15,7 +15,7 @@
     if 'test' in bld.env['MODULES_NOT_BUILT']:
         return
 
-    test = bld.create_ns3_module('test', ['internet', 'mobility', 'applications', 'csma', 'bridge', 'config-store', 'tools', 'point-to-point', 'csma-layout', 'flow-monitor', 'wifi'])
+    test = bld.create_ns3_module('test', ['internet', 'mobility', 'applications', 'csma', 'bridge', 'config-store', 'point-to-point', 'csma-layout', 'flow-monitor', 'wifi'])
     headers = bld(features='ns3header')
     headers.module = 'test'
 
--- a/src/tools/model/average.h	Tue Jun 18 13:21:35 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 IITP RAS
- *
- * 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
- *
- * Authors: Pavel Boyko <boyko@iitp.ru>
- * Corrections and extensions: Timo Bingmann <tbns@idlebox.net>
- */
-
-#ifndef AVERAGE_H
-#define AVERAGE_H
-#include <cmath>
-#include <ostream>
-#include <limits>
-#include <stdint.h>
-#include "ns3/basic-data-calculators.h"
-
-namespace ns3 {
-
-/**
- * \defgroup tools Tools
- *
- */
-
-/**
- * \ingroup tools
- *
- * Simple average, min, max and std. deviation calculator
- *
- */
-
-template <typename T = double>
-class Average
-{
-public:
-  Average ()
-    : m_size (0), m_min (std::numeric_limits<T>::max ()), m_max (0)
-  {
-  }
-
-  /// Add new sample
-  void Update (T const & x)
-  {
-    // Give the variance calculator the next value.
-    m_varianceCalculator.Update (x);
-
-    m_min = std::min (x, m_min);
-    m_max = std::max (x, m_max);
-    m_size++;
-  }
-  /// Reset statistics
-  void Reset ()
-  {
-    m_varianceCalculator.Reset ();
-
-    m_size = 0;
-    m_min = std::numeric_limits<T>::max ();
-    m_max = 0;
-  }
-
-  ///\name Sample statistics
-  //\{
-  /// Sample size
-  uint32_t Count   () const { return m_size; }
-  /// Minimum
-  T        Min     () const { return m_min; }
-  /// Maximum
-  T        Max     () const { return m_max; }
-  /// Sample average
-  double   Avg     () const { return m_varianceCalculator.getMean ();}
-  /// Estimate of mean, alias to Avg
-  double   Mean    () const { return Avg (); }
-  /// Unbiased estimate of variance
-  double   Var     () const { return m_varianceCalculator.getVariance ();}
-  /// Standard deviation
-  double   Stddev  () const { return std::sqrt (Var ()); }
-  //\}
-
-  /** 
-   * \name Error of the mean estimates
-   *
-   * Note that estimates are valid for 
-   *   - uncorrelated measurements, 
-   *   - normal distribution and
-   *   - large enough sample size.
-   */
-  //\{
-  /// Margin of error of the mean for 90% confidence level 
-  double   Error90 () const { return 1.645 * std::sqrt (Var () / Count ()); }
-  /// Margin of error of the mean for 95% confidence level 
-  double   Error95 () const { return 1.960 * std::sqrt (Var () / Count ()); }
-  /// Margin of error of the mean for 99% confidence level 
-  double   Error99 () const { return 2.576 * std::sqrt (Var () / Count ()); }
-  //\}
-
-private:
-  uint32_t m_size;
-  T      m_min, m_max;
-  MinMaxAvgTotalCalculator<double> m_varianceCalculator;
-};
-
-/// Print avg (err) [min, max]
-template <typename T>
-std::ostream & operator<< (std::ostream & os, Average<T> const & x)
-{
-  if (x.Count () != 0)
-    os << x.Avg () << " (" << x.Stddev () << ") [" << x.Min () << ", " << x.Max () << "]";
-  else
-    os << "NA";  // not available
-  return os;
-}
-}
-#endif /* AVERAGE_H */
--- a/src/tools/test/average-test-suite.cc	Tue Jun 18 13:21:35 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2012 University of Washington
- *
- * 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: Mitch Watrous (watrous@u.washington.edu)
- */
-
-#include <cmath>
-
-#include "ns3/test.h"
-#include "ns3/average.h"
-
-using namespace ns3;
-
-const double TOLERANCE = 1e-14;
-
-// ===========================================================================
-// Test case for a single integer.
-// ===========================================================================
-
-class OneIntegerAverageTestCase : public TestCase
-{
-public:
-  OneIntegerAverageTestCase ();
-  virtual ~OneIntegerAverageTestCase ();
-
-private:
-  virtual void DoRun (void);
-};
-
-OneIntegerAverageTestCase::OneIntegerAverageTestCase ()
-  : TestCase ("Average Object Test using One Integer")
-
-{
-}
-
-OneIntegerAverageTestCase::~OneIntegerAverageTestCase ()
-{
-}
-
-void
-OneIntegerAverageTestCase::DoRun (void)
-{
-  Average<int> calculator;
-
-  long count = 1;
-
-  double sum = 0;
-  double sqrSum = 0;
-  double min;
-  double max;
-  double mean;
-  double stddev;
-  double variance;
-
-  // Put all of the values into the calculator.
-  int multiple = 5;
-  int value;
-  for (long i = 0; i < count; i++)
-    {
-      value = multiple * (i + 1);
-
-      calculator.Update (value);
-
-      sum    += value;
-      sqrSum += value * value;
-    }
-
-  // Calculate the expected values for the statistical functions.
-  min = multiple;
-  max = multiple * count;
-  mean = sum / count;
-  variance = 0;
-  stddev = std::sqrt (variance);
-
-  // Test the calculator.
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (),    count,    TOLERANCE, "Count value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Min (),      min,      TOLERANCE, "Min value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Max (),      max,      TOLERANCE, "Max value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Mean (),     mean,     TOLERANCE, "Mean value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Stddev (),   stddev,   TOLERANCE, "Stddev value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Var (), variance, TOLERANCE, "Variance value wrong");
-}
-
-
-// ===========================================================================
-// Test case for five integers.
-// ===========================================================================
-
-class FiveIntegersAverageTestCase : public TestCase
-{
-public:
-  FiveIntegersAverageTestCase ();
-  virtual ~FiveIntegersAverageTestCase ();
-
-private:
-  virtual void DoRun (void);
-};
-
-FiveIntegersAverageTestCase::FiveIntegersAverageTestCase ()
-  : TestCase ("Average Object Test using Five Integers")
-
-{
-}
-
-FiveIntegersAverageTestCase::~FiveIntegersAverageTestCase ()
-{
-}
-
-void
-FiveIntegersAverageTestCase::DoRun (void)
-{
-  Average<int> calculator;
-
-  long count = 5;
-
-  double sum = 0;
-  double sqrSum = 0;
-  double min;
-  double max;
-  double mean;
-  double stddev;
-  double variance;
-
-  // Put all of the values into the calculator.
-  int multiple = 5;
-  int value;
-  for (long i = 0; i < count; i++)
-    {
-      value = multiple * (i + 1);
-
-      calculator.Update (value);
-
-      sum    += value;
-      sqrSum += value * value;
-    }
-
-  // Calculate the expected values for the statistical functions.
-  min = multiple;
-  max = multiple * count;
-  mean = sum / count;
-  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-  stddev = std::sqrt (variance);
-
-  // Test the calculator.
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (),    count,    TOLERANCE, "Count value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Min (),      min,      TOLERANCE, "Min value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Max (),      max,      TOLERANCE, "Max value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Mean (),     mean,     TOLERANCE, "Mean value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Stddev (),   stddev,   TOLERANCE, "Stddev value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Var (), variance, TOLERANCE, "Variance value wrong");
-}
-
-
-// ===========================================================================
-// Test case for five double values.
-// ===========================================================================
-
-class FiveDoublesAverageTestCase : public TestCase
-{
-public:
-  FiveDoublesAverageTestCase ();
-  virtual ~FiveDoublesAverageTestCase ();
-
-private:
-  virtual void DoRun (void);
-};
-
-FiveDoublesAverageTestCase::FiveDoublesAverageTestCase ()
-  : TestCase ("Average Object Test using Five Double Values")
-
-{
-}
-
-FiveDoublesAverageTestCase::~FiveDoublesAverageTestCase ()
-{
-}
-
-void
-FiveDoublesAverageTestCase::DoRun (void)
-{
-  Average<double> calculator;
-
-  long count = 5;
-
-  double sum = 0;
-  double sqrSum = 0;
-  double min;
-  double max;
-  double mean;
-  double stddev;
-  double variance;
-
-  // Put all of the values into the calculator.
-  double multiple = 3.14;
-  double value;
-  for (long i = 0; i < count; i++)
-    {
-      value = multiple * (i + 1);
-
-      calculator.Update (value);
-
-      sum    += value;
-      sqrSum += value * value;
-    }
-
-  // Calculate the expected values for the statistical functions.
-  min = multiple;
-  max = multiple * count;
-  mean = sum / count;
-  variance = (count * sqrSum - sum * sum) / (count * (count - 1));
-  stddev = std::sqrt (variance);
-
-  // Test the calculator.
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (),    count,    TOLERANCE, "Count value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Min (),      min,      TOLERANCE, "Min value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Max (),      max,      TOLERANCE, "Max value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Mean (),     mean,     TOLERANCE, "Mean value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Stddev (),   stddev,   TOLERANCE, "Stddev value wrong");
-  NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Var (), variance, TOLERANCE, "Variance value wrong");
-}
-
-
-class AverageTestSuite : public TestSuite
-{
-public:
-  AverageTestSuite ();
-};
-
-AverageTestSuite::AverageTestSuite ()
-  : TestSuite ("average", UNIT)
-{
-  AddTestCase (new OneIntegerAverageTestCase, TestCase::QUICK);
-  AddTestCase (new FiveIntegersAverageTestCase, TestCase::QUICK);
-  AddTestCase (new FiveDoublesAverageTestCase, TestCase::QUICK);
-}
-
-static AverageTestSuite averageTestSuite;
--- a/src/tools/wscript	Tue Jun 18 13:21:35 2013 -0700
+++ b/src/tools/wscript	Tue Jun 18 13:42:57 2013 -0700
@@ -8,12 +8,10 @@
 
     module_test = bld.create_ns3_module_test_library('tools')
     module_test.source = [
-        'test/average-test-suite.cc',
         ]
     
     headers = bld(features='ns3header')
     headers.module = 'tools'
     headers.source = [
-        'model/average.h',
         ]