23 #include "ns3/boolean.h"
24 #include "ns3/double.h"
25 #include "ns3/integer.h"
27 #include "ns3/random-variable-stream.h"
28 #include "ns3/rng-seed-manager.h"
29 #include "ns3/string.h"
35 #include <gsl/gsl_cdf.h>
36 #include <gsl/gsl_histogram.h>
37 #include <gsl/gsl_sf_zeta.h>
49 namespace RandomVariable
95 bool underflow =
true,
96 bool overflow =
true)
const
99 std::size_t nBins = gsl_histogram_bins(h);
100 double increment = (end -
start) / (nBins - 1.);
103 std::vector<double> range(nBins + 1);
105 for (
auto& r : range)
119 gsl_histogram_set_ranges(h, range.data(), nBins + 1);
157 template <
typename RNG>
173 auto rng = CreateObject<RNG>();
199 const std::vector<double>& expected,
204 "Histogram and expected vector have different sizes.");
210 gsl_histogram_increment(h,
value);
214 double chiSquared = 0;
215 std::size_t nBins = gsl_histogram_bins(h);
216 for (std::size_t i = 0; i < nBins; ++i)
218 double hbin = gsl_histogram_get(h, i);
219 double tmp = hbin - expected[i];
276 for (std::size_t i = 0; i < nRuns; ++i)
278 auto rng = generator->
Create();
282 sum /= (double)nRuns;
324 seed =
static_cast<uint32_t
>(time(
nullptr));
327 "Special run number value of zero; seeding with time of day: " << seed);
361 void DoRun()
override;
365 :
TestCaseBase(
"Uniform Random Variable Stream Generator")
372 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
376 gsl_histogram_set_ranges_uniform(h, 0., 1.);
380 double chiSquared =
ChiSquared(h, expected, rng);
381 gsl_histogram_free(h);
391 double confidence = 0.99;
392 double maxStatistic = gsl_cdf_chisq_Pinv(confidence, (
N_BINS - 1));
394 <<
" bins is " << maxStatistic);
396 double result = maxStatistic;
398 for (uint32_t i = 0; i <
N_RUNS; ++i)
403 if (result < maxStatistic)
433 static const uint32_t UNIFORM_INTEGER_MIN{0};
434 static const uint32_t UNIFORM_INTEGER_MAX{4294967295U};
437 intValue =
x->GetInteger(UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN);
440 intValue =
x->GetInteger(UNIFORM_INTEGER_MAX, UNIFORM_INTEGER_MAX);
444 for (
int i = 0; i < 20; i++)
446 intValue +=
x->GetInteger(UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN + 1);
452 for (
int i = 0; i < 20; i++)
454 intValue =
x->GetInteger(UNIFORM_INTEGER_MAX - 1, UNIFORM_INTEGER_MAX);
455 if (intValue == UNIFORM_INTEGER_MAX)
463 intValue =
x->GetInteger(UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
464 uint32_t intValue2 =
x->GetInteger(UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
483 void DoRun()
override;
487 :
TestCaseBase(
"Antithetic Uniform Random Variable Stream Generator")
494 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
498 gsl_histogram_set_ranges_uniform(h, 0., 1.);
502 double chiSquared =
ChiSquared(h, expected, rng);
503 gsl_histogram_free(h);
515 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
555 void DoRun()
override;
562 :
TestCaseBase(
"Constant Random Variable Stream Generator")
590 "Constant value changed in loop");
606 void DoRun()
override;
613 :
TestCaseBase(
"Sequential Random Variable Stream Generator")
631 s->SetAttribute(
"Increment",
StringValue(
"ns3::UniformRandomVariable[Min=3.0|Max=3.0]"));
637 value = s->GetValue();
639 value = s->GetValue();
641 value = s->GetValue();
643 value = s->GetValue();
645 value = s->GetValue();
647 value = s->GetValue();
666 void DoRun()
override;
673 :
TestCaseBase(
"Normal Random Variable Stream Generator")
680 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
683 std::vector<double> expected(
N_BINS);
690 for (std::size_t i = 0; i <
N_BINS; ++i)
692 expected[i] = gsl_cdf_gaussian_P(range[i + 1],
sigma) - gsl_cdf_gaussian_P(range[i],
sigma);
696 double chiSquared =
ChiSquared(h, expected, rng);
697 gsl_histogram_free(h);
708 auto rng = generator.Create();
711 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
715 double variance = 2.0;
727 double expectedMean = mean;
734 "Wrong mean value.");
752 void DoRun()
override;
759 :
TestCaseBase(
"Antithetic Normal Random Variable Stream Generator")
766 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
769 std::vector<double> expected(
N_BINS);
776 for (std::size_t i = 0; i <
N_BINS; ++i)
778 expected[i] = gsl_cdf_gaussian_P(range[i + 1],
sigma) - gsl_cdf_gaussian_P(range[i],
sigma);
782 double chiSquared =
ChiSquared(h, expected, rng);
784 gsl_histogram_free(h);
796 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
800 double variance = 2.0;
815 double expectedMean = mean;
822 "Wrong mean value.");
840 void DoRun()
override;
847 :
TestCaseBase(
"Exponential Random Variable Stream Generator")
854 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
857 std::vector<double> expected(
N_BINS);
863 for (std::size_t i = 0; i <
N_BINS; ++i)
865 expected[i] = gsl_cdf_exponential_P(range[i + 1], mu) - gsl_cdf_exponential_P(range[i], mu);
869 double chiSquared =
ChiSquared(h, expected, rng);
871 gsl_histogram_free(h);
883 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
896 double expectedMean = mean;
903 "Wrong mean value.");
921 void DoRun()
override;
928 :
TestCaseBase(
"Antithetic Exponential Random Variable Stream Generator")
935 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
938 std::vector<double> expected(
N_BINS);
944 for (std::size_t i = 0; i <
N_BINS; ++i)
946 expected[i] = gsl_cdf_exponential_P(range[i + 1], mu) - gsl_cdf_exponential_P(range[i], mu);
950 double chiSquared =
ChiSquared(h, expected, rng);
952 gsl_histogram_free(h);
964 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
980 double expectedMean = mean;
987 "Wrong mean value.");
1005 void DoRun()
override;
1015 :
TestCaseBase(
"Pareto Random Variable Stream Generator")
1022 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1025 std::vector<double> expected(
N_BINS);
1030 for (std::size_t i = 0; i <
N_BINS; ++i)
1033 gsl_cdf_pareto_P(range[i + 1], shape, scale) - gsl_cdf_pareto_P(range[i], shape, scale);
1037 double chiSquared =
ChiSquared(h, expected, rng);
1039 gsl_histogram_free(h);
1051 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1074 double expectedMean = (shape * scale) / (shape - 1.0);
1080 "Wrong mean value.");
1098 void DoRun()
override;
1108 :
TestCaseBase(
"Antithetic Pareto Random Variable Stream Generator")
1115 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1118 std::vector<double> expected(
N_BINS);
1123 for (std::size_t i = 0; i <
N_BINS; ++i)
1126 gsl_cdf_pareto_P(range[i + 1], shape, scale) - gsl_cdf_pareto_P(range[i], shape, scale);
1130 double chiSquared =
ChiSquared(h, expected, rng);
1132 gsl_histogram_free(h);
1144 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1171 double expectedMean = (shape * scale) / (shape - 1.0);
1177 "Wrong mean value.");
1195 void DoRun()
override;
1205 :
TestCaseBase(
"Weibull Random Variable Stream Generator")
1212 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1215 std::vector<double> expected(
N_BINS);
1223 for (std::size_t i = 0; i <
N_BINS; ++i)
1225 expected[i] = gsl_cdf_weibull_P(range[i + 1], a, b) - gsl_cdf_weibull_P(range[i], a, b);
1230 double chiSquared =
ChiSquared(h, expected, rng);
1232 gsl_histogram_free(h);
1244 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1280 double expectedMean = scale;
1286 "Wrong mean value.");
1304 void DoRun()
override;
1314 :
TestCaseBase(
"Antithetic Weibull Random Variable Stream Generator")
1321 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1324 std::vector<double> expected(
N_BINS);
1332 for (std::size_t i = 0; i <
N_BINS; ++i)
1334 expected[i] = gsl_cdf_weibull_P(range[i + 1], a, b) - gsl_cdf_weibull_P(range[i], a, b);
1338 double chiSquared =
ChiSquared(h, expected, rng);
1340 gsl_histogram_free(h);
1352 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1391 double expectedMean = scale;
1397 "Wrong mean value.");
1415 void DoRun()
override;
1425 :
TestCaseBase(
"Log-Normal Random Variable Stream Generator")
1432 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1435 std::vector<double> expected(
N_BINS);
1443 for (std::size_t i = 0; i <
N_BINS; ++i)
1446 gsl_cdf_lognormal_P(range[i + 1], mu,
sigma) - gsl_cdf_lognormal_P(range[i], mu,
sigma);
1450 double chiSquared =
ChiSquared(h, expected, rng);
1452 gsl_histogram_free(h);
1464 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1486 double expectedMean = std::exp(mu +
sigma *
sigma / 2.0);
1499 "Wrong mean value.");
1517 void DoRun()
override;
1527 :
TestCaseBase(
"Antithetic Log-Normal Random Variable Stream Generator")
1534 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1537 std::vector<double> expected(
N_BINS);
1545 for (std::size_t i = 0; i <
N_BINS; ++i)
1548 gsl_cdf_lognormal_P(range[i + 1], mu,
sigma) - gsl_cdf_lognormal_P(range[i], mu,
sigma);
1552 double chiSquared =
ChiSquared(h, expected, rng);
1554 gsl_histogram_free(h);
1566 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1590 double expectedMean = std::exp(mu +
sigma *
sigma / 2.0);
1603 "Wrong mean value.");
1621 void DoRun()
override;
1631 :
TestCaseBase(
"Gamma Random Variable Stream Generator")
1638 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1641 std::vector<double> expected(
N_BINS);
1649 for (std::size_t i = 0; i <
N_BINS; ++i)
1652 gsl_cdf_gamma_P(range[i + 1], alpha, beta) - gsl_cdf_gamma_P(range[i], alpha, beta);
1656 double chiSquared =
ChiSquared(h, expected, rng);
1658 gsl_histogram_free(h);
1670 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1689 double expectedMean = alpha * beta;
1695 "Wrong mean value.");
1713 void DoRun()
override;
1723 :
TestCaseBase(
"Antithetic Gamma Random Variable Stream Generator")
1730 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1733 std::vector<double> expected(
N_BINS);
1741 for (std::size_t i = 0; i <
N_BINS; ++i)
1744 gsl_cdf_gamma_P(range[i + 1], alpha, beta) - gsl_cdf_gamma_P(range[i], alpha, beta);
1748 double chiSquared =
ChiSquared(h, expected, rng);
1750 gsl_histogram_free(h);
1762 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1785 double expectedMean = alpha * beta;
1791 "Wrong mean value.");
1809 void DoRun()
override;
1819 :
TestCaseBase(
"Erlang Random Variable Stream Generator")
1826 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1829 std::vector<double> expected(
N_BINS);
1835 double lambda = 1.0;
1840 for (std::size_t i = 0; i <
N_BINS; ++i)
1843 gsl_cdf_gamma_P(range[i + 1],
k, lambda) - gsl_cdf_gamma_P(range[i],
k, lambda);
1847 double chiSquared =
ChiSquared(h, expected, rng);
1849 gsl_histogram_free(h);
1861 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1865 double lambda = 2.0;
1880 double expectedMean =
k * lambda;
1886 "Wrong mean value.");
1904 void DoRun()
override;
1914 :
TestCaseBase(
"Antithetic Erlang Random Variable Stream Generator")
1921 gsl_histogram* h = gsl_histogram_alloc(
N_BINS);
1924 std::vector<double> expected(
N_BINS);
1930 double lambda = 1.0;
1935 for (std::size_t i = 0; i <
N_BINS; ++i)
1938 gsl_cdf_gamma_P(range[i + 1],
k, lambda) - gsl_cdf_gamma_P(range[i],
k, lambda);
1942 double chiSquared =
ChiSquared(h, expected, rng);
1944 gsl_histogram_free(h);
1956 double maxStatistic = gsl_cdf_chisq_Qinv(0.05,
N_BINS);
1960 double lambda = 2.0;
1979 double expectedMean =
k * lambda;
1985 "Wrong mean value.");
2000 void DoRun()
override;
2010 :
TestCaseBase(
"Zipf Random Variable Stream Generator")
2059 double expectedMean = 1.0;
2065 "Wrong mean value.");
2080 void DoRun()
override;
2090 :
TestCaseBase(
"Antithetic Zipf Random Variable Stream Generator")
2142 double expectedMean = 1.0;
2148 "Wrong mean value.");
2163 void DoRun()
override;
2173 :
TestCaseBase(
"Zeta Random Variable Stream Generator")
2204 double expectedMean =
2205 gsl_sf_zeta_int(
static_cast<int>(alpha - 1)) / gsl_sf_zeta_int(
static_cast<int>(alpha));
2211 "Wrong mean value.");
2226 void DoRun()
override;
2236 :
TestCaseBase(
"Antithetic Zeta Random Variable Stream Generator")
2270 double expectedMean =
2271 gsl_sf_zeta_int(
static_cast<int>(alpha) - 1) / gsl_sf_zeta_int(
static_cast<int>(alpha));
2277 "Wrong mean value.");
2292 void DoRun()
override;
2299 :
TestCaseBase(
"Deterministic Random Variable Stream Generator")
2315 double array1[] = {4, 4, 7, 7, 10, 10};
2316 std::size_t count1 = 6;
2317 s->SetValueArray(array1, count1);
2322 value = s->GetValue();
2324 value = s->GetValue();
2326 value = s->GetValue();
2328 value = s->GetValue();
2330 value = s->GetValue();
2332 value = s->GetValue();
2339 double array2[] = {1000, 2000, 3000, 4000};
2340 std::size_t count2 = 4;
2341 s->SetValueArray(array2, count2);
2344 value = s->GetValue();
2346 value = s->GetValue();
2348 value = s->GetValue();
2350 value = s->GetValue();
2352 value = s->GetValue();
2367 void DoRun()
override;
2377 :
TestCaseBase(
"Empirical Random Variable Stream Generator")
2389 x->SetInterpolate(
false);
2397 double value =
x->GetValue();
2400 "Incorrect value returned, expected only 5 or 10.");
2416 double expectedMean = 8.75;
2420 "Wrong mean value.");
2423 x->SetInterpolate(
true);
2438 expectedMean = 6.25;
2444 "Wrong mean value.");
2448 y->SetInterpolate(
false);
2467 void DoRun()
override;
2477 :
TestCaseBase(
"EmpiricalAntithetic Random Variable Stream Generator")
2489 x->SetInterpolate(
false);
2500 double value =
x->GetValue();
2503 "Incorrect value returned, expected only 5 or 10.");
2510 double expectedMean = 8.75;
2514 "Wrong mean value.");
2517 x->SetInterpolate(
true);
2525 expectedMean = 6.25;
2531 "Wrong mean value.");
2546 void DoRun()
override;
2550 :
TestCaseBase(
"NormalRandomVariable caching of parameters")
2561 double v1 = n->GetValue(-10, 1, 10);
2562 double v2 = n->GetValue(10, 1, 10);
2581 :
TestSuite(
"random-variable-stream-generators", UNIT)
AttributeValue implementation for Boolean.
double GetValue(double constant)
Get the next random value drawn from the distribution.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold a signed integer type.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
static void SetSeed(uint32_t seed)
Set the seed.
static uint64_t GetRun()
Get the current run number.
static uint32_t GetSeed()
Get the current seed value which will be used by all subsequently instantiated RandomVariableStream o...
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Test case for constant random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation.
void DoRun() override
Implementation to actually run this TestCase.
Test case for deterministic random variable stream generator.
void DoRun() override
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation.
Test case for antithetic empirical distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
EmpiricalAntitheticTestCase()
Test case for empirical distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
Test case for antithetic Erlang distribution random variable stream generator.
void DoRun() override
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
ErlangAntitheticTestCase()
Test case for Erlang distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
void DoRun() override
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
Test case for antithetic exponential distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
void DoRun() override
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
ExponentialAntitheticTestCase()
Test case for exponential distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
void DoRun() override
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
Test case for antithetic gamma distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
GammaAntitheticTestCase()
void DoRun() override
Implementation to actually run this TestCase.
Test case for gamma distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
Test case for antithetic log-normal distribution random variable stream generator.
void DoRun() override
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
LogNormalAntitheticTestCase()
Test case for log-normal distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
Test case for antithetic normal distribution random variable stream generator.
NormalAntitheticTestCase()
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
void DoRun() override
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
Test case for caching of Normal RV parameters (see issue #302)
void DoRun() override
Implementation to actually run this TestCase.
Test case for normal distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
void DoRun() override
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
Test case for antithetic Pareto distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
ParetoAntitheticTestCase()
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
Test case for Pareto distribution random variable stream generator.
void DoRun() override
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
RandomVariableStream test suite, covering all random number variable stream generator types.
Test case for sequential random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation.
void DoRun() override
Implementation to actually run this TestCase.
A factory base class to create new instances of a random variable.
virtual Ptr< RandomVariableStream > Create() const =0
Create a new instance of a random variable stream.
Factory class to create new instances of a particular random variable stream.
Ptr< RandomVariableStream > Create() const override
Create a new instance of a random variable stream.
bool m_anti
Whether to create antithetic random variable streams.
RngGenerator(bool anti=false)
Constructor.
Base class for RandomVariableStream test suites.
double ChiSquared(gsl_histogram *h, const std::vector< double > &expected, Ptr< RandomVariableStream > rng) const
Compute the chi squared value of a sampled distribution compared to the expected distribution.
static const uint32_t N_MEASUREMENTS
Number of samples to draw when populating the distributions.
void SetTestSuiteSeed()
Set the seed used for this test suite.
double ChiSquaredsAverage(const RngGeneratorBase *generator, std::size_t nRuns) const
Average the chi squared value over some number of runs, each run with a new instance of the random nu...
virtual double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
static const uint32_t N_BINS
Number of bins for sampling the distributions.
std::vector< double > UniformHistogramBins(gsl_histogram *h, double start, double end, bool underflow=true, bool overflow=true) const
Configure a GSL histogram with uniform bins, with optional under/over-flow bins.
bool m_seedSet
true if we've already set the seed the correctly.
TestCaseBase(std::string name)
Constructor.
static const uint32_t N_RUNS
Number of retry attempts to pass a chi-square test.
double Average(Ptr< RandomVariableStream > rng) const
Compute the average of a random variable.
Test case for antithetic Weibull distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
WeibullAntitheticTestCase()
Test case for Weibull distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const override
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
Test case for antithetic Zeta distribution random variable stream generator.
void DoRun() override
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
Test case for Zeta distribution random variable stream generator.
void DoRun() override
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
Test case for antithetic Zipf distribution random variable stream generator.
void DoRun() override
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
Test case for Zipf distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void DoRun() override
Implementation to actually run this TestCase.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#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.
#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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#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.
#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.
#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 RandomVariableSuite randomVariableSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.