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"
37 #include "ns3/rng-seed-manager.h"
38 #include "ns3/random-variable-stream.h"
47 double increment = (end -
start) / (n - 1.);
50 for (uint32_t i = 0; i < n; ++i)
65 static const uint32_t N_RUNS = 5;
66 static const uint32_t N_BINS = 50;
67 static const uint32_t N_MEASUREMENTS = 1000000;
75 virtual void DoRun (
void);
79 :
TestCase (
"Uniform Random Variable Stream Generator")
90 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
94 gsl_histogram_set_ranges_uniform (h, 0., 1.);
98 gsl_histogram_increment (h, u->
GetValue ());
103 double expected = ((double)N_MEASUREMENTS / (
double)
N_BINS);
105 for (uint32_t i = 0; i <
N_BINS; ++i)
107 tmp[i] = gsl_histogram_get (h, i);
113 gsl_histogram_free (h);
115 double chiSquared = 0;
117 for (uint32_t i = 0; i <
N_BINS; ++i)
119 chiSquared += tmp[i];
128 SeedManager::SetSeed (time (0));
131 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
133 for (uint32_t i = 0; i <
N_RUNS; ++i)
140 sum /= (double)N_RUNS;
166 static const uint32_t UNIFORM_INTEGER_MIN = 0;
167 static const uint32_t UNIFORM_INTEGER_MAX = 4294967295U;
170 intValue = x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN);
173 intValue = x->
GetInteger (UNIFORM_INTEGER_MAX, UNIFORM_INTEGER_MAX);
177 for (
int i = 0; i < 20; i++)
179 intValue += x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN + 1);
185 for (
int i = 0; i < 20; i++)
187 intValue = x->
GetInteger (UNIFORM_INTEGER_MAX - 1, UNIFORM_INTEGER_MAX);
188 if (intValue == UNIFORM_INTEGER_MAX)
196 intValue = x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
197 uint32_t intValue2 = x->
GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
218 virtual void DoRun (
void);
222 :
TestCase (
"Antithetic Uniform Random Variable Stream Generator")
233 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
237 gsl_histogram_set_ranges_uniform (h, 0., 1.);
241 gsl_histogram_increment (h, u->
GetValue ());
246 double expected = ((double)N_MEASUREMENTS / (
double)
N_BINS);
248 for (uint32_t i = 0; i <
N_BINS; ++i)
250 tmp[i] = gsl_histogram_get (h, i);
256 gsl_histogram_free (h);
258 double chiSquared = 0;
260 for (uint32_t i = 0; i <
N_BINS; ++i)
262 chiSquared += tmp[i];
271 SeedManager::SetSeed (time (0));
274 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
276 for (uint32_t i = 0; i <
N_RUNS; ++i)
287 sum /= (double)N_RUNS;
331 virtual void DoRun (
void);
337 :
TestCase (
"Constant Random Variable Stream Generator")
348 SeedManager::SetSeed (time (0));
381 virtual void DoRun (
void);
387 :
TestCase (
"Sequential Random Variable Stream Generator")
398 SeedManager::SetSeed (time (0));
445 virtual void DoRun (
void);
449 :
TestCase (
"Normal Random Variable Stream Generator")
460 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
464 range[0] = -std::numeric_limits<double>::max ();
465 range[
N_BINS] = std::numeric_limits<double>::max ();
467 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
476 for (uint32_t i = 0; i <
N_BINS; ++i)
478 expected[i] = gsl_cdf_gaussian_P (range[i + 1], sigma) - gsl_cdf_gaussian_P (range[i], sigma);
484 gsl_histogram_increment (h, n->
GetValue ());
489 for (uint32_t i = 0; i <
N_BINS; ++i)
491 tmp[i] = gsl_histogram_get (h, i);
492 tmp[i] -= expected[i];
494 tmp[i] /= expected[i];
497 gsl_histogram_free (h);
499 double chiSquared = 0;
501 for (uint32_t i = 0; i <
N_BINS; ++i)
503 chiSquared += tmp[i];
512 SeedManager::SetSeed (time (0));
515 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
517 for (uint32_t i = 0; i <
N_RUNS; ++i)
524 sum /= (double)N_RUNS;
529 double variance = 2.0;
548 double expectedMean = mean;
571 virtual void DoRun (
void);
575 :
TestCase (
"Antithetic Normal Random Variable Stream Generator")
586 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
590 range[0] = -std::numeric_limits<double>::max ();
591 range[
N_BINS] = std::numeric_limits<double>::max ();
593 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
602 for (uint32_t i = 0; i <
N_BINS; ++i)
604 expected[i] = gsl_cdf_gaussian_P (range[i + 1], sigma) - gsl_cdf_gaussian_P (range[i], sigma);
610 gsl_histogram_increment (h, n->
GetValue ());
615 for (uint32_t i = 0; i <
N_BINS; ++i)
617 tmp[i] = gsl_histogram_get (h, i);
618 tmp[i] -= expected[i];
620 tmp[i] /= expected[i];
623 gsl_histogram_free (h);
625 double chiSquared = 0;
627 for (uint32_t i = 0; i <
N_BINS; ++i)
629 chiSquared += tmp[i];
638 SeedManager::SetSeed (time (0));
641 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
643 for (uint32_t i = 0; i <
N_RUNS; ++i)
654 sum /= (double)N_RUNS;
659 double variance = 2.0;
681 double expectedMean = mean;
704 virtual void DoRun (
void);
708 :
TestCase (
"Exponential Random Variable Stream Generator")
719 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
723 range[
N_BINS] = std::numeric_limits<double>::max ();
725 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
733 for (uint32_t i = 0; i <
N_BINS; ++i)
735 expected[i] = gsl_cdf_exponential_P (range[i + 1], mu) - gsl_cdf_exponential_P (range[i], mu);
741 gsl_histogram_increment (h, e->
GetValue ());
746 for (uint32_t i = 0; i <
N_BINS; ++i)
748 tmp[i] = gsl_histogram_get (h, i);
749 tmp[i] -= expected[i];
751 tmp[i] /= expected[i];
754 gsl_histogram_free (h);
756 double chiSquared = 0;
758 for (uint32_t i = 0; i <
N_BINS; ++i)
760 chiSquared += tmp[i];
769 SeedManager::SetSeed (time (0));
772 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
774 for (uint32_t i = 0; i <
N_RUNS; ++i)
781 sum /= (double)N_RUNS;
824 virtual void DoRun (
void);
828 :
TestCase (
"Antithetic Exponential Random Variable Stream Generator")
839 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
843 range[
N_BINS] = std::numeric_limits<double>::max ();
845 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
853 for (uint32_t i = 0; i <
N_BINS; ++i)
855 expected[i] = gsl_cdf_exponential_P (range[i + 1], mu) - gsl_cdf_exponential_P (range[i], mu);
861 gsl_histogram_increment (h, e->
GetValue ());
866 for (uint32_t i = 0; i <
N_BINS; ++i)
868 tmp[i] = gsl_histogram_get (h, i);
869 tmp[i] -= expected[i];
871 tmp[i] /= expected[i];
874 gsl_histogram_free (h);
876 double chiSquared = 0;
878 for (uint32_t i = 0; i <
N_BINS; ++i)
880 chiSquared += tmp[i];
889 SeedManager::SetSeed (time (0));
892 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
894 for (uint32_t i = 0; i <
N_RUNS; ++i)
905 sum /= (double)N_RUNS;
951 virtual void DoRun (
void);
955 :
TestCase (
"Pareto Random Variable Stream Generator")
966 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
970 range[
N_BINS] = std::numeric_limits<double>::max ();
972 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
980 double scale = mean * (shape - 1.0) / shape;
982 for (uint32_t i = 0; i <
N_BINS; ++i)
984 expected[i] = gsl_cdf_pareto_P (range[i + 1], shape, scale) - gsl_cdf_pareto_P (range[i], shape, scale);
990 gsl_histogram_increment (h, p->
GetValue ());
995 for (uint32_t i = 0; i <
N_BINS; ++i)
997 tmp[i] = gsl_histogram_get (h, i);
998 tmp[i] -= expected[i];
1000 tmp[i] /= expected[i];
1003 gsl_histogram_free (h);
1005 double chiSquared = 0;
1007 for (uint32_t i = 0; i <
N_BINS; ++i)
1009 chiSquared += tmp[i];
1018 SeedManager::SetSeed (time (0));
1021 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1023 for (uint32_t i = 0; i <
N_RUNS; ++i)
1030 sum /= (double)N_RUNS;
1036 double scale = mean * (shape - 1.0) / shape;
1062 double expectedMean = (shape * scale) / (shape - 1.0);
1085 virtual void DoRun (
void);
1089 :
TestCase (
"Antithetic Pareto Random Variable Stream Generator")
1100 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1102 double range[
N_BINS + 1];
1104 range[
N_BINS] = std::numeric_limits<double>::max ();
1106 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
1114 double scale = mean * (shape - 1.0) / shape;
1116 for (uint32_t i = 0; i <
N_BINS; ++i)
1118 expected[i] = gsl_cdf_pareto_P (range[i + 1], shape, scale) - gsl_cdf_pareto_P (range[i], shape, scale);
1124 gsl_histogram_increment (h, p->
GetValue ());
1129 for (uint32_t i = 0; i <
N_BINS; ++i)
1131 tmp[i] = gsl_histogram_get (h, i);
1132 tmp[i] -= expected[i];
1134 tmp[i] /= expected[i];
1137 gsl_histogram_free (h);
1139 double chiSquared = 0;
1141 for (uint32_t i = 0; i <
N_BINS; ++i)
1143 chiSquared += tmp[i];
1152 SeedManager::SetSeed (time (0));
1155 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1157 for (uint32_t i = 0; i <
N_RUNS; ++i)
1168 sum /= (double)N_RUNS;
1174 double scale = mean * (shape - 1.0) / shape;
1204 double expectedMean = (shape * scale) / (shape - 1.0);
1227 virtual void DoRun (
void);
1231 :
TestCase (
"Weibull Random Variable Stream Generator")
1242 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1244 double range[
N_BINS + 1];
1246 range[
N_BINS] = std::numeric_limits<double>::max ();
1248 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
1258 for (uint32_t i = 0; i <
N_BINS; ++i)
1260 expected[i] = gsl_cdf_weibull_P (range[i + 1], a, b) - gsl_cdf_weibull_P (range[i], a, b);
1266 gsl_histogram_increment (h, p->
GetValue ());
1271 for (uint32_t i = 0; i <
N_BINS; ++i)
1273 tmp[i] = gsl_histogram_get (h, i);
1274 tmp[i] -= expected[i];
1276 tmp[i] /= expected[i];
1279 gsl_histogram_free (h);
1281 double chiSquared = 0;
1283 for (uint32_t i = 0; i <
N_BINS; ++i)
1285 chiSquared += tmp[i];
1294 SeedManager::SetSeed (time (0));
1297 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1299 for (uint32_t i = 0; i <
N_RUNS; ++i)
1306 sum /= (double)N_RUNS;
1350 double expectedMean = scale;
1373 virtual void DoRun (
void);
1377 :
TestCase (
"Antithetic Weibull Random Variable Stream Generator")
1388 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1390 double range[
N_BINS + 1];
1392 range[
N_BINS] = std::numeric_limits<double>::max ();
1394 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
1404 for (uint32_t i = 0; i <
N_BINS; ++i)
1406 expected[i] = gsl_cdf_weibull_P (range[i + 1], a, b) - gsl_cdf_weibull_P (range[i], a, b);
1412 gsl_histogram_increment (h, p->
GetValue ());
1417 for (uint32_t i = 0; i <
N_BINS; ++i)
1419 tmp[i] = gsl_histogram_get (h, i);
1420 tmp[i] -= expected[i];
1422 tmp[i] /= expected[i];
1425 gsl_histogram_free (h);
1427 double chiSquared = 0;
1429 for (uint32_t i = 0; i <
N_BINS; ++i)
1431 chiSquared += tmp[i];
1440 SeedManager::SetSeed (time (0));
1443 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1445 for (uint32_t i = 0; i <
N_RUNS; ++i)
1456 sum /= (double)N_RUNS;
1503 double expectedMean = scale;
1526 virtual void DoRun (
void);
1530 :
TestCase (
"Log-Normal Random Variable Stream Generator")
1541 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1543 double range[
N_BINS + 1];
1545 range[
N_BINS] = std::numeric_limits<double>::max ();
1547 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
1557 for (uint32_t i = 0; i <
N_BINS; ++i)
1559 expected[i] = gsl_cdf_lognormal_P (range[i + 1], mu, sigma) - gsl_cdf_lognormal_P (range[i], mu, sigma);
1565 gsl_histogram_increment (h, n->
GetValue ());
1570 for (uint32_t i = 0; i <
N_BINS; ++i)
1572 tmp[i] = gsl_histogram_get (h, i);
1573 tmp[i] -= expected[i];
1575 tmp[i] /= expected[i];
1578 gsl_histogram_free (h);
1580 double chiSquared = 0;
1582 for (uint32_t i = 0; i <
N_BINS; ++i)
1584 chiSquared += tmp[i];
1593 SeedManager::SetSeed (time (0));
1596 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1598 for (uint32_t i = 0; i <
N_RUNS; ++i)
1605 sum /= (double)N_RUNS;
1634 double expectedMean = std::exp(mu + sigma * sigma / 2.0);
1662 virtual void DoRun (
void);
1666 :
TestCase (
"Antithetic Log-Normal Random Variable Stream Generator")
1677 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1679 double range[
N_BINS + 1];
1681 range[
N_BINS] = std::numeric_limits<double>::max ();
1683 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
1693 for (uint32_t i = 0; i <
N_BINS; ++i)
1695 expected[i] = gsl_cdf_lognormal_P (range[i + 1], mu, sigma) - gsl_cdf_lognormal_P (range[i], mu, sigma);
1701 gsl_histogram_increment (h, n->
GetValue ());
1706 for (uint32_t i = 0; i <
N_BINS; ++i)
1708 tmp[i] = gsl_histogram_get (h, i);
1709 tmp[i] -= expected[i];
1711 tmp[i] /= expected[i];
1714 gsl_histogram_free (h);
1716 double chiSquared = 0;
1718 for (uint32_t i = 0; i <
N_BINS; ++i)
1720 chiSquared += tmp[i];
1729 SeedManager::SetSeed (time (0));
1732 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1734 for (uint32_t i = 0; i <
N_RUNS; ++i)
1745 sum /= (double)N_RUNS;
1777 double expectedMean = std::exp(mu + sigma * sigma / 2.0);
1805 virtual void DoRun (
void);
1809 :
TestCase (
"Gamma Random Variable Stream Generator")
1820 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1822 double range[
N_BINS + 1];
1824 range[
N_BINS] = std::numeric_limits<double>::max ();
1826 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
1836 for (uint32_t i = 0; i <
N_BINS; ++i)
1838 expected[i] = gsl_cdf_gamma_P (range[i + 1], alpha, beta) - gsl_cdf_gamma_P (range[i], alpha, beta);
1844 gsl_histogram_increment (h, n->
GetValue ());
1849 for (uint32_t i = 0; i <
N_BINS; ++i)
1851 tmp[i] = gsl_histogram_get (h, i);
1852 tmp[i] -= expected[i];
1854 tmp[i] /= expected[i];
1857 gsl_histogram_free (h);
1859 double chiSquared = 0;
1861 for (uint32_t i = 0; i <
N_BINS; ++i)
1863 chiSquared += tmp[i];
1872 SeedManager::SetSeed (time (0));
1875 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1877 for (uint32_t i = 0; i <
N_RUNS; ++i)
1884 sum /= (double)N_RUNS;
1911 double expectedMean = alpha * beta;
1934 virtual void DoRun (
void);
1938 :
TestCase (
"Antithetic Gamma Random Variable Stream Generator")
1949 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1951 double range[
N_BINS + 1];
1953 range[
N_BINS] = std::numeric_limits<double>::max ();
1955 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
1965 for (uint32_t i = 0; i <
N_BINS; ++i)
1967 expected[i] = gsl_cdf_gamma_P (range[i + 1], alpha, beta) - gsl_cdf_gamma_P (range[i], alpha, beta);
1973 gsl_histogram_increment (h, n->
GetValue ());
1978 for (uint32_t i = 0; i <
N_BINS; ++i)
1980 tmp[i] = gsl_histogram_get (h, i);
1981 tmp[i] -= expected[i];
1983 tmp[i] /= expected[i];
1986 gsl_histogram_free (h);
1988 double chiSquared = 0;
1990 for (uint32_t i = 0; i <
N_BINS; ++i)
1992 chiSquared += tmp[i];
2001 SeedManager::SetSeed (time (0));
2004 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
2006 for (uint32_t i = 0; i <
N_RUNS; ++i)
2017 sum /= (double)N_RUNS;
2048 double expectedMean = alpha * beta;
2071 virtual void DoRun (
void);
2075 :
TestCase (
"Erlang Random Variable Stream Generator")
2086 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
2088 double range[
N_BINS + 1];
2090 range[
N_BINS] = std::numeric_limits<double>::max ();
2092 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
2100 double lambda = 1.0;
2105 for (uint32_t i = 0; i <
N_BINS; ++i)
2107 expected[i] = gsl_cdf_gamma_P (range[i + 1], k, lambda) - gsl_cdf_gamma_P (range[i], k, lambda);
2113 gsl_histogram_increment (h, n->
GetValue ());
2118 for (uint32_t i = 0; i <
N_BINS; ++i)
2120 tmp[i] = gsl_histogram_get (h, i);
2121 tmp[i] -= expected[i];
2123 tmp[i] /= expected[i];
2126 gsl_histogram_free (h);
2128 double chiSquared = 0;
2130 for (uint32_t i = 0; i <
N_BINS; ++i)
2132 chiSquared += tmp[i];
2141 SeedManager::SetSeed (time (0));
2144 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
2146 for (uint32_t i = 0; i <
N_RUNS; ++i)
2153 sum /= (double)N_RUNS;
2158 double lambda = 2.0;
2180 double expectedMean = k * lambda;
2203 virtual void DoRun (
void);
2207 :
TestCase (
"Antithetic Erlang Random Variable Stream Generator")
2218 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
2220 double range[
N_BINS + 1];
2222 range[
N_BINS] = std::numeric_limits<double>::max ();
2224 gsl_histogram_set_ranges (h, range,
N_BINS + 1);
2232 double lambda = 1.0;
2237 for (uint32_t i = 0; i <
N_BINS; ++i)
2239 expected[i] = gsl_cdf_gamma_P (range[i + 1], k, lambda) - gsl_cdf_gamma_P (range[i], k, lambda);
2245 gsl_histogram_increment (h, n->
GetValue ());
2250 for (uint32_t i = 0; i <
N_BINS; ++i)
2252 tmp[i] = gsl_histogram_get (h, i);
2253 tmp[i] -= expected[i];
2255 tmp[i] /= expected[i];
2258 gsl_histogram_free (h);
2260 double chiSquared = 0;
2262 for (uint32_t i = 0; i <
N_BINS; ++i)
2264 chiSquared += tmp[i];
2273 SeedManager::SetSeed (time (0));
2276 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
2278 for (uint32_t i = 0; i <
N_RUNS; ++i)
2289 sum /= (double)N_RUNS;
2294 double lambda = 2.0;
2320 double expectedMean = k * lambda;
2339 virtual void DoRun (
void);
2343 :
TestCase (
"Zipf Random Variable Stream Generator")
2354 SeedManager::SetSeed (time (0));
2402 double expectedMean = 1.0;
2421 virtual void DoRun (
void);
2425 :
TestCase (
"Antithetic Zipf Random Variable Stream Generator")
2436 SeedManager::SetSeed (time (0));
2487 double expectedMean = 1.0;
2506 virtual void DoRun (
void);
2510 :
TestCase (
"Zeta Random Variable Stream Generator")
2521 SeedManager::SetSeed (time (0));
2551 double expectedMean = gsl_sf_zeta_int (alpha - 1) / gsl_sf_zeta_int (alpha);
2570 virtual void DoRun (
void);
2574 :
TestCase (
"Antithetic Zeta Random Variable Stream Generator")
2585 SeedManager::SetSeed (time (0));
2618 double expectedMean = gsl_sf_zeta_int (alpha - 1) / gsl_sf_zeta_int (alpha);
2637 virtual void DoRun (
void);
2643 :
TestCase (
"Deterministic Random Variable Stream Generator")
2654 SeedManager::SetSeed (time (0));
2662 double array1 [] = { 4, 4, 7, 7, 10, 10};
2663 uint64_t count1 = 6;
2686 double array2 [] = { 1000, 2000, 3000, 4000};
2687 uint64_t count2 = 4;
2714 virtual void DoRun (
void);
2718 :
TestCase (
"Empirical Random Variable Stream Generator")
2729 SeedManager::SetSeed (time (0));
2752 double expectedMean = 5.0;
2771 virtual void DoRun (
void);
2775 :
TestCase (
"EmpiricalAntithetic Random Variable Stream Generator")
2786 SeedManager::SetSeed (time (0));
2812 double expectedMean = 5.0;
2826 :
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)
Returns the value passed in.
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()
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()
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
virtual void DoRun(void)
Implementation to actually run this TestCase.
static const uint32_t N_BINS
virtual ~RandomVariableStreamZipfAntitheticTestCase()
virtual ~RandomVariableStreamGammaAntitheticTestCase()
virtual double GetValue(void)
Returns the next value in the sequence returned by this RNG stream.
static const double TOLERANCE
static const uint32_t N_MEASUREMENTS
static const uint32_t N_MEASUREMENTS
RandomVariableStreamWeibullTestCase()
RandomVariableStreamZetaTestCase()
virtual ~RandomVariableStreamNormalTestCase()
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()
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
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
static const uint32_t N_BINS
double ChiSquaredTest(Ptr< WeibullRandomVariable > p)
virtual ~RandomVariableStreamParetoAntitheticTestCase()
double ChiSquaredTest(Ptr< GammaRandomVariable > n)
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()
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)
Returns a random double from an exponential distribution with the specified mean and upper bound...
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.
Hold a floating point type.
static const uint32_t N_MEASUREMENTS
void SetAttribute(std::string name, const AttributeValue &value)
virtual ~RandomVariableStreamConstantTestCase()
RandomVariableStreamEmpiricalAntitheticTestCase()
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