25 #include <gsl/gsl_cdf.h> 
   26 #include <gsl/gsl_histogram.h> 
   27 #include <gsl/gsl_sf_zeta.h> 
   32 #include "ns3/boolean.h" 
   33 #include "ns3/double.h" 
   34 #include "ns3/string.h" 
   35 #include "ns3/integer.h" 
   38 #include "ns3/rng-seed-manager.h" 
   39 #include "ns3/random-variable-stream.h" 
   50   double increment = (end - 
start) / (n - 1.);
 
   53   for (uint32_t i = 0; i < n; ++i)
 
   95           seed = 
static_cast<uint32_t
> (time (0));
 
   97           NS_LOG_DEBUG (
"Global seed and run number are default; seeding with time of day: " << seed);
 
  104           NS_LOG_DEBUG (
"Global seed and run number are not default; using the non-default values seed: " <<
 
  121   static const uint32_t N_BINS = 100;
 
  122   static const uint32_t N_MEASUREMENTS = 1000000;
 
  125   static const uint32_t N_RUNS = 2;
 
  133   virtual void DoRun (
void);
 
  137   : 
TestCase (
"Uniform Random Variable Stream Generator")
 
  148   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
  152   gsl_histogram_set_ranges_uniform (h, 0., 1.);
 
  156       gsl_histogram_increment (h, u->
GetValue ());
 
  161   double expected = ((double)N_MEASUREMENTS / (
double)
N_BINS);
 
  163   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  165       tmp[i] = gsl_histogram_get (h, i);
 
  171   gsl_histogram_free (h);
 
  173   double chiSquared = 0;
 
  175   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  177       chiSquared += tmp[i];
 
  188   double confidence = 0.99;
 
  189   double maxStatistic = gsl_cdf_chisq_Pinv (confidence, (
N_BINS-1));
 
  190   NS_LOG_DEBUG (
"Chi square required at " << confidence << 
" confidence for " << 
N_BINS << 
" bins is " << maxStatistic);
 
  192   double result = maxStatistic;
 
  194   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
  199       if (result < maxStatistic)
 
  229   static const uint32_t UNIFORM_INTEGER_MIN = 0;
 
  230   static const uint32_t UNIFORM_INTEGER_MAX = 4294967295U;
 
  233   intValue = x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN);
 
  236   intValue = x->
GetInteger (UNIFORM_INTEGER_MAX, UNIFORM_INTEGER_MAX);
 
  240   for (
int i = 0; i < 20; i++)
 
  242       intValue += x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN + 1);
 
  248   for (
int i = 0; i < 20; i++)
 
  250       intValue = x->
GetInteger (UNIFORM_INTEGER_MAX - 1, UNIFORM_INTEGER_MAX);
 
  251       if (intValue == UNIFORM_INTEGER_MAX)
 
  259   intValue = x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
 
  260   uint32_t intValue2 = x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
 
  281   virtual void DoRun (
void);
 
  285   : 
TestCase (
"Antithetic Uniform Random Variable Stream Generator")
 
  296   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
  300   gsl_histogram_set_ranges_uniform (h, 0., 1.);
 
  304       gsl_histogram_increment (h, u->
GetValue ());
 
  309   double expected = ((double)N_MEASUREMENTS / (
double)
N_BINS);
 
  311   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  313       tmp[i] = gsl_histogram_get (h, i);
 
  319   gsl_histogram_free (h);
 
  321   double chiSquared = 0;
 
  323   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  325       chiSquared += tmp[i];
 
  337   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
  339   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
  350   sum /= (double)N_RUNS;
 
  394   virtual void DoRun (
void);
 
  400   : 
TestCase (
"Constant Random Variable Stream Generator")
 
  444   virtual void DoRun (
void);
 
  450   : 
TestCase (
"Sequential Random Variable Stream Generator")
 
  508   virtual void DoRun (
void);
 
  512   : 
TestCase (
"Normal Random Variable Stream Generator")
 
  523   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
  527   range[0] = -std::numeric_limits<double>::max ();
 
  528   range[
N_BINS] = std::numeric_limits<double>::max ();
 
  530   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
  539   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  541       expected[i] = gsl_cdf_gaussian_P (range[i + 1], sigma) - gsl_cdf_gaussian_P (range[i], sigma);
 
  547       gsl_histogram_increment (h, n->
GetValue ());
 
  552   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  554       tmp[i] = gsl_histogram_get (h, i);
 
  555       tmp[i] -= expected[i];
 
  557       tmp[i] /= expected[i];
 
  560   gsl_histogram_free (h);
 
  562   double chiSquared = 0;
 
  564   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  566       chiSquared += tmp[i];
 
  578   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
  580   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
  587   sum /= (double)N_RUNS;
 
  592   double variance = 2.0;
 
  611   double expectedMean = mean;
 
  634   virtual void DoRun (
void);
 
  638   : 
TestCase (
"Antithetic Normal Random Variable Stream Generator")
 
  649   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
  653   range[0] = -std::numeric_limits<double>::max ();
 
  654   range[
N_BINS] = std::numeric_limits<double>::max ();
 
  656   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
  665   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  667       expected[i] = gsl_cdf_gaussian_P (range[i + 1], sigma) - gsl_cdf_gaussian_P (range[i], sigma);
 
  673       gsl_histogram_increment (h, n->
GetValue ());
 
  678   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  680       tmp[i] = gsl_histogram_get (h, i);
 
  681       tmp[i] -= expected[i];
 
  683       tmp[i] /= expected[i];
 
  686   gsl_histogram_free (h);
 
  688   double chiSquared = 0;
 
  690   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  692       chiSquared += tmp[i];
 
  704   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
  706   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
  717   sum /= (double)N_RUNS;
 
  722   double variance = 2.0;
 
  744   double expectedMean = mean;
 
  767   virtual void DoRun (
void);
 
  771   : 
TestCase (
"Exponential Random Variable Stream Generator")
 
  782   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
  786   range[
N_BINS] = std::numeric_limits<double>::max ();
 
  788   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
  796   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  798       expected[i] = gsl_cdf_exponential_P (range[i + 1], mu) - gsl_cdf_exponential_P (range[i], mu);
 
  804       gsl_histogram_increment (h, e->
GetValue ());
 
  809   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  811       tmp[i] = gsl_histogram_get (h, i);
 
  812       tmp[i] -= expected[i];
 
  814       tmp[i] /= expected[i];
 
  817   gsl_histogram_free (h);
 
  819   double chiSquared = 0;
 
  821   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  823       chiSquared += tmp[i];
 
  835   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
  837   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
  844   sum /= (double)N_RUNS;
 
  887   virtual void DoRun (
void);
 
  891   : 
TestCase (
"Antithetic Exponential Random Variable Stream Generator")
 
  902   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
  906   range[
N_BINS] = std::numeric_limits<double>::max ();
 
  908   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
  916   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  918       expected[i] = gsl_cdf_exponential_P (range[i + 1], mu) - gsl_cdf_exponential_P (range[i], mu);
 
  924       gsl_histogram_increment (h, e->
GetValue ());
 
  929   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  931       tmp[i] = gsl_histogram_get (h, i);
 
  932       tmp[i] -= expected[i];
 
  934       tmp[i] /= expected[i];
 
  937   gsl_histogram_free (h);
 
  939   double chiSquared = 0;
 
  941   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
  943       chiSquared += tmp[i];
 
  955   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
  957   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
  968   sum /= (double)N_RUNS;
 
 1014   virtual void DoRun (
void);
 
 1018   : 
TestCase (
"Pareto Random Variable Stream Generator")
 
 1029   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 1031   double range[
N_BINS + 1];
 
 1033   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 1035   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 1043   double scale = mean * (shape - 1.0) / shape;
 
 1045   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1047       expected[i] = gsl_cdf_pareto_P (range[i + 1], shape, scale) - gsl_cdf_pareto_P (range[i], shape, scale);
 
 1053       gsl_histogram_increment (h, p->
GetValue ());
 
 1058   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1060       tmp[i] = gsl_histogram_get (h, i);
 
 1061       tmp[i] -= expected[i];
 
 1063       tmp[i] /= expected[i];
 
 1066   gsl_histogram_free (h);
 
 1068   double chiSquared = 0;
 
 1070   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1072       chiSquared += tmp[i];
 
 1084   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 1086   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 1093   sum /= (double)N_RUNS;
 
 1099   double scale = mean * (shape - 1.0) / shape;
 
 1125   double expectedMean = (shape * scale) / (shape - 1.0);
 
 1148   virtual void DoRun (
void);
 
 1152   : 
TestCase (
"Antithetic Pareto Random Variable Stream Generator")
 
 1163   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 1165   double range[
N_BINS + 1];
 
 1167   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 1169   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 1177   double scale = mean * (shape - 1.0) / shape;
 
 1179   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1181       expected[i] = gsl_cdf_pareto_P (range[i + 1], shape, scale) - gsl_cdf_pareto_P (range[i], shape, scale);
 
 1187       gsl_histogram_increment (h, p->
GetValue ());
 
 1192   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1194       tmp[i] = gsl_histogram_get (h, i);
 
 1195       tmp[i] -= expected[i];
 
 1197       tmp[i] /= expected[i];
 
 1200   gsl_histogram_free (h);
 
 1202   double chiSquared = 0;
 
 1204   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1206       chiSquared += tmp[i];
 
 1218   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 1220   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 1231   sum /= (double)N_RUNS;
 
 1237   double scale = mean * (shape - 1.0) / shape;
 
 1267   double expectedMean = (shape * scale) / (shape - 1.0);
 
 1290   virtual void DoRun (
void);
 
 1294   : 
TestCase (
"Weibull Random Variable Stream Generator")
 
 1305   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 1307   double range[
N_BINS + 1];
 
 1309   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 1311   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 1321   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1323       expected[i] = gsl_cdf_weibull_P (range[i + 1], a, b) - gsl_cdf_weibull_P (range[i], a, b);
 
 1329       gsl_histogram_increment (h, p->
GetValue ());
 
 1334   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1336       tmp[i] = gsl_histogram_get (h, i);
 
 1337       tmp[i] -= expected[i];
 
 1339       tmp[i] /= expected[i];
 
 1342   gsl_histogram_free (h);
 
 1344   double chiSquared = 0;
 
 1346   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1348       chiSquared += tmp[i];
 
 1360   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 1362   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 1369   sum /= (double)N_RUNS;
 
 1413   double expectedMean = scale;
 
 1436   virtual void DoRun (
void);
 
 1440   : 
TestCase (
"Antithetic Weibull Random Variable Stream Generator")
 
 1451   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 1453   double range[
N_BINS + 1];
 
 1455   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 1457   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 1467   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1469       expected[i] = gsl_cdf_weibull_P (range[i + 1], a, b) - gsl_cdf_weibull_P (range[i], a, b);
 
 1475       gsl_histogram_increment (h, p->
GetValue ());
 
 1480   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1482       tmp[i] = gsl_histogram_get (h, i);
 
 1483       tmp[i] -= expected[i];
 
 1485       tmp[i] /= expected[i];
 
 1488   gsl_histogram_free (h);
 
 1490   double chiSquared = 0;
 
 1492   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1494       chiSquared += tmp[i];
 
 1506   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 1508   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 1519   sum /= (double)N_RUNS;
 
 1566   double expectedMean = scale;
 
 1589   virtual void DoRun (
void);
 
 1593   : 
TestCase (
"Log-Normal Random Variable Stream Generator")
 
 1604   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 1606   double range[
N_BINS + 1];
 
 1608   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 1610   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 1620   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1622       expected[i] = gsl_cdf_lognormal_P (range[i + 1], mu, sigma) - gsl_cdf_lognormal_P (range[i], mu, sigma);
 
 1628       gsl_histogram_increment (h, n->
GetValue ());
 
 1633   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1635       tmp[i] = gsl_histogram_get (h, i);
 
 1636       tmp[i] -= expected[i];
 
 1638       tmp[i] /= expected[i];
 
 1641   gsl_histogram_free (h);
 
 1643   double chiSquared = 0;
 
 1645   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1647       chiSquared += tmp[i];
 
 1659   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 1661   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 1668   sum /= (double)N_RUNS;
 
 1697   double expectedMean = std::exp(mu + sigma * sigma / 2.0);
 
 1725   virtual void DoRun (
void);
 
 1729   : 
TestCase (
"Antithetic Log-Normal Random Variable Stream Generator")
 
 1740   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 1742   double range[
N_BINS + 1];
 
 1744   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 1746   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 1756   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1758       expected[i] = gsl_cdf_lognormal_P (range[i + 1], mu, sigma) - gsl_cdf_lognormal_P (range[i], mu, sigma);
 
 1764       gsl_histogram_increment (h, n->
GetValue ());
 
 1769   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1771       tmp[i] = gsl_histogram_get (h, i);
 
 1772       tmp[i] -= expected[i];
 
 1774       tmp[i] /= expected[i];
 
 1777   gsl_histogram_free (h);
 
 1779   double chiSquared = 0;
 
 1781   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1783       chiSquared += tmp[i];
 
 1795   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 1797   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 1808   sum /= (double)N_RUNS;
 
 1840   double expectedMean = std::exp(mu + sigma * sigma / 2.0);
 
 1868   virtual void DoRun (
void);
 
 1872   : 
TestCase (
"Gamma Random Variable Stream Generator")
 
 1883   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 1885   double range[
N_BINS + 1];
 
 1887   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 1889   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 1899   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1901       expected[i] = gsl_cdf_gamma_P (range[i + 1], alpha, beta) - gsl_cdf_gamma_P (range[i], alpha, beta);
 
 1907       gsl_histogram_increment (h, n->
GetValue ());
 
 1912   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1914       tmp[i] = gsl_histogram_get (h, i);
 
 1915       tmp[i] -= expected[i];
 
 1917       tmp[i] /= expected[i];
 
 1920   gsl_histogram_free (h);
 
 1922   double chiSquared = 0;
 
 1924   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 1926       chiSquared += tmp[i];
 
 1938   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 1940   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 1947   sum /= (double)N_RUNS;
 
 1974   double expectedMean = alpha * beta;
 
 1997   virtual void DoRun (
void);
 
 2001   : 
TestCase (
"Antithetic Gamma Random Variable Stream Generator")
 
 2012   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 2014   double range[
N_BINS + 1];
 
 2016   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 2018   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 2028   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2030       expected[i] = gsl_cdf_gamma_P (range[i + 1], alpha, beta) - gsl_cdf_gamma_P (range[i], alpha, beta);
 
 2036       gsl_histogram_increment (h, n->
GetValue ());
 
 2041   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2043       tmp[i] = gsl_histogram_get (h, i);
 
 2044       tmp[i] -= expected[i];
 
 2046       tmp[i] /= expected[i];
 
 2049   gsl_histogram_free (h);
 
 2051   double chiSquared = 0;
 
 2053   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2055       chiSquared += tmp[i];
 
 2067   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 2069   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 2080   sum /= (double)N_RUNS;
 
 2111   double expectedMean = alpha * beta;
 
 2134   virtual void DoRun (
void);
 
 2138   : 
TestCase (
"Erlang Random Variable Stream Generator")
 
 2149   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 2151   double range[
N_BINS + 1];
 
 2153   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 2155   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 2163   double lambda = 1.0;
 
 2168   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2170       expected[i] = gsl_cdf_gamma_P (range[i + 1], k, lambda) - gsl_cdf_gamma_P (range[i], k, lambda);
 
 2176       gsl_histogram_increment (h, n->
GetValue ());
 
 2181   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2183       tmp[i] = gsl_histogram_get (h, i);
 
 2184       tmp[i] -= expected[i];
 
 2186       tmp[i] /= expected[i];
 
 2189   gsl_histogram_free (h);
 
 2191   double chiSquared = 0;
 
 2193   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2195       chiSquared += tmp[i];
 
 2207   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 2209   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 2216   sum /= (double)N_RUNS;
 
 2221   double lambda = 2.0;
 
 2243   double expectedMean = k * lambda;
 
 2266   virtual void DoRun (
void);
 
 2270   : 
TestCase (
"Antithetic Erlang Random Variable Stream Generator")
 
 2281   gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
 
 2283   double range[
N_BINS + 1];
 
 2285   range[
N_BINS] = std::numeric_limits<double>::max ();
 
 2287   gsl_histogram_set_ranges (h, range, 
N_BINS + 1);
 
 2295   double lambda = 1.0;
 
 2300   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2302       expected[i] = gsl_cdf_gamma_P (range[i + 1], k, lambda) - gsl_cdf_gamma_P (range[i], k, lambda);
 
 2308       gsl_histogram_increment (h, n->
GetValue ());
 
 2313   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2315       tmp[i] = gsl_histogram_get (h, i);
 
 2316       tmp[i] -= expected[i];
 
 2318       tmp[i] /= expected[i];
 
 2321   gsl_histogram_free (h);
 
 2323   double chiSquared = 0;
 
 2325   for (uint32_t i = 0; i < 
N_BINS; ++i)
 
 2327       chiSquared += tmp[i];
 
 2339   double maxStatistic = gsl_cdf_chisq_Qinv (0.05, 
N_BINS);
 
 2341   for (uint32_t i = 0; i < 
N_RUNS; ++i)
 
 2352   sum /= (double)N_RUNS;
 
 2357   double lambda = 2.0;
 
 2383   double expectedMean = k * lambda;
 
 2402   virtual void DoRun (
void);
 
 2406   : 
TestCase (
"Zipf Random Variable Stream Generator")
 
 2465   double expectedMean = 1.0;
 
 2484   virtual void DoRun (
void);
 
 2488   : 
TestCase (
"Antithetic Zipf Random Variable Stream Generator")
 
 2550   double expectedMean = 1.0;
 
 2569   virtual void DoRun (
void);
 
 2573   : 
TestCase (
"Zeta Random Variable Stream Generator")
 
 2614   double expectedMean = gsl_sf_zeta_int (alpha - 1) / gsl_sf_zeta_int (alpha);
 
 2633   virtual void DoRun (
void);
 
 2637   : 
TestCase (
"Antithetic Zeta Random Variable Stream Generator")
 
 2681   double expectedMean = gsl_sf_zeta_int (alpha - 1) / gsl_sf_zeta_int (alpha);
 
 2700   virtual void DoRun (
void);
 
 2706   : 
TestCase (
"Deterministic Random Variable Stream Generator")
 
 2725   double array1 [] = { 4, 4, 7, 7, 10, 10};
 
 2726   uint64_t count1 = 6;
 
 2749   double array2 [] = { 1000, 2000, 3000, 4000};
 
 2750   uint64_t count2 = 4;
 
 2777   virtual void DoRun (
void);
 
 2781   : 
TestCase (
"Empirical Random Variable Stream Generator")
 
 2815   double expectedMean = 5.0;
 
 2841   virtual void DoRun (
void);
 
 2845   : 
TestCase (
"EmpiricalAntithetic Random Variable Stream Generator")
 
 2882   double expectedMean = 5.0;
 
 2896   : 
TestSuite (
"random-variable-stream-generators", UNIT)
 
static const uint32_t N_MEASUREMENTS
 
virtual ~RandomVariableStreamExponentialAntitheticTestCase()
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_RUNS
 
virtual double GetValue(void)
Returns the next value in the empirical distribution. 
 
double GetValue(double constant)
Get the next random value, as a double equal to the argument. 
 
static const uint32_t N_RUNS
 
double ChiSquaredTest(Ptr< LogNormalRandomVariable > n)
 
void FillHistoRangeUniformly(double *array, uint32_t n, double start, double end)
 
RandomVariableStreamLogNormalAntitheticTestCase()
 
virtual ~RandomVariableStreamZipfTestCase()
 
AttributeValue implementation for Boolean. 
 
RandomVariableStreamGammaTestCase()
 
static const uint32_t N_RUNS
 
virtual ~RandomVariableStreamExponentialTestCase()
 
virtual ~RandomVariableStreamZetaAntitheticTestCase()
 
Hold variables of type string. 
 
static RandomVariableStreamTestSuite randomVariableStreamTestSuite
 
RandomVariableStreamExponentialAntitheticTestCase()
 
virtual ~RandomVariableStreamGammaTestCase()
 
static const uint32_t N_RUNS
 
RandomVariableStreamTestSuite()
 
static const uint32_t N_RUNS
 
RandomVariableStreamParetoAntitheticTestCase()
 
virtual ~RandomVariableStreamEmpiricalTestCase()
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_RUNS
 
double ChiSquaredTest(Ptr< LogNormalRandomVariable > n)
 
virtual ~RandomVariableStreamLogNormalAntitheticTestCase()
 
static const uint32_t N_MEASUREMENTS
 
Hold a signed integer type. 
 
double GetValue(uint32_t k, double lambda)
Returns a random double from an Erlang distribution with the specified k and lambda. 
 
RandomVariableStreamExponentialTestCase()
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
virtual ~RandomVariableStreamErlangAntitheticTestCase()
 
double GetValue(double mean, double shape, double bound)
Returns a random double from a Pareto distribution with the specified mean, shape, and upper bound. 
 
static const uint32_t N_BINS
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
double GetValue(double mean, double variance, double bound=NormalRandomVariable::INFINITE_VALUE)
Returns a random double from a normal distribution with the specified mean, variance, and bound. 
 
double GetValue(double alpha)
Returns a random double from a zeta distribution with the specified alpha. 
 
RandomVariableStreamConstantTestCase()
 
double ChiSquaredTest(Ptr< NormalRandomVariable > n)
 
double ChiSquaredTest(Ptr< ExponentialRandomVariable > e)
 
static const uint32_t N_BINS
 
static const uint32_t N_MEASUREMENTS
 
double ChiSquaredTest(Ptr< ExponentialRandomVariable > e)
 
double ChiSquaredTest(Ptr< WeibullRandomVariable > p)
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
static const uint32_t N_BINS
 
static const uint32_t N_RUNS
 
static const uint32_t N_RUNS
 
static const uint32_t N_BINS
 
static const uint32_t N_RUNS
 
static uint64_t GetRun(void)
Get the current run number. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
static const uint32_t N_BINS
 
virtual ~RandomVariableStreamZipfAntitheticTestCase()
 
virtual ~RandomVariableStreamGammaAntitheticTestCase()
 
virtual double GetValue(void)
Get the next random value as a double drawn from the distribution. 
 
static const double TOLERANCE
 
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution. 
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_MEASUREMENTS
 
RandomVariableStreamWeibullTestCase()
 
RandomVariableStreamZetaTestCase()
 
virtual ~RandomVariableStreamNormalTestCase()
 
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite. 
 
RandomVariableStreamZipfAntitheticTestCase()
 
virtual double GetValue(void)
Returns the next value in the sequence. 
 
double ChiSquaredTest(Ptr< ErlangRandomVariable > n)
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_RUNS
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
static const uint32_t N_BINS
 
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not. 
 
static const uint32_t N_BINS
 
double GetValue(double alpha, double beta)
Returns a random double from a gamma distribution with the specified alpha and beta. 
 
void CDF(double v, double c)
Specifies a point in the empirical distribution. 
 
virtual ~RandomVariableStreamNormalAntitheticTestCase()
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_BINS
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
RandomVariableStreamZipfTestCase()
 
static const uint32_t N_BINS
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_BINS
 
double ChiSquaredTest(Ptr< GammaRandomVariable > n)
 
RandomVariableStreamZetaAntitheticTestCase()
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
 
static const uint32_t N_RUNS
 
static const double TOLERANCE
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
double ChiSquaredTest(Ptr< NormalRandomVariable > n)
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual ~RandomVariableStreamErlangTestCase()
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
double GetValue(double mu, double sigma)
Returns a random double from a log-normal distribution with the specified mu and sigma. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
static const uint32_t N_MEASUREMENTS
 
virtual ~RandomVariableStreamWeibullTestCase()
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
RandomVariableStreamNormalAntitheticTestCase()
 
RandomVariableStreamSequentialTestCase()
 
void SetValueArray(double *values, uint64_t length)
Sets the array of values that holds the predetermined sequence. 
 
virtual ~RandomVariableStreamParetoTestCase()
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual ~RandomVariableStreamLogNormalTestCase()
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_BINS
 
double ChiSquaredTest(Ptr< WeibullRandomVariable > p)
 
static uint32_t GetSeed(void)
Get the current seed value which will be used by all subsequently instantiated RandomVariableStream o...
 
virtual ~RandomVariableStreamParetoAntitheticTestCase()
 
double ChiSquaredTest(Ptr< GammaRandomVariable > n)
 
static void SetSeed(uint32_t seed)
Set the seed. 
 
RandomVariableStreamDeterministicTestCase()
 
static const uint32_t N_BINS
 
static const uint32_t N_BINS
 
static const uint32_t N_MEASUREMENTS
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
static const uint32_t N_MEASUREMENTS
 
RandomVariableStreamErlangAntitheticTestCase()
 
virtual ~RandomVariableStreamZetaTestCase()
 
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not...
 
virtual ~RandomVariableStreamEmpiricalAntitheticTestCase()
 
static const uint32_t N_MEASUREMENTS
 
RandomVariableStreamErlangTestCase()
 
double ChiSquaredTest(Ptr< ParetoRandomVariable > p)
 
RandomVariableStreamEmpiricalTestCase()
 
RandomVariableStreamWeibullAntitheticTestCase()
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_RUNS
 
static const uint32_t N_RUNS
 
static const uint32_t N_MEASUREMENTS
 
virtual ~RandomVariableStreamWeibullAntitheticTestCase()
 
double GetValue(double mean, double bound)
Get the next random value, as a double from the exponential distribution with the specified mean and ...
 
RandomVariableStreamParetoTestCase()
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
static const double TOLERANCE
 
double ChiSquaredTest(Ptr< ParetoRandomVariable > p)
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
RandomVariableStreamNormalTestCase()
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
RandomVariableStreamLogNormalTestCase()
 
static const uint32_t N_BINS
 
double GetValue(uint32_t n, double alpha)
Returns a random double from a Zipf distribution with the specified n and alpha. 
 
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not. 
 
This class can be used to hold variables of floating point type such as 'double' or 'float'...
 
static const uint32_t N_MEASUREMENTS
 
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful. 
 
virtual ~RandomVariableStreamConstantTestCase()
 
RandomVariableStreamEmpiricalAntitheticTestCase()
 
void SetTestSuiteSeed(void)
 
static const uint32_t N_RUNS
 
static const uint32_t N_MEASUREMENTS
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
double ChiSquaredTest(Ptr< ErlangRandomVariable > n)
 
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not. 
 
double GetValue(double scale, double shape, double bound)
Returns a random double from a Weibull distribution with the specified scale, shape, and upper bound. 
 
virtual ~RandomVariableStreamDeterministicTestCase()
 
RandomVariableStreamGammaAntitheticTestCase()
 
virtual ~RandomVariableStreamSequentialTestCase()
 
static const uint32_t N_MEASUREMENTS
 
static const uint32_t N_MEASUREMENTS