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" 49 namespace RandomVariable {
85 bool underflow =
true,
bool overflow =
true)
const 88 std::size_t nBins = gsl_histogram_bins (h);
89 double increment = (end -
start) / (nBins - 1.);
92 std::vector<double> range (nBins + 1);
94 for (
auto & r : range)
108 gsl_histogram_set_ranges (h, range.data (), nBins + 1);
124 double value =
rng->GetValue ();
147 template <
typename RNG>
163 auto rng = CreateObject<RNG> ();
190 const std::vector<double> & expected,
195 "Histogram and expected vector have different sizes.");
200 double value =
rng->GetValue ();
201 gsl_histogram_increment (h, value);
205 double chiSquared = 0;
206 std::size_t nBins = gsl_histogram_bins (h);
207 for (std::size_t i = 0; i < nBins; ++i)
209 double hbin = gsl_histogram_get (h, i);
210 double tmp = hbin - expected[i];
265 std::size_t nRuns)
const 270 for (std::size_t i = 0; i < nRuns; ++i)
276 sum /= (double)nRuns;
316 seed =
static_cast<uint32_t
> (time (0));
318 NS_LOG_DEBUG (
"Global seed and run number are default; seeding with time of day: " << seed);
325 NS_LOG_DEBUG (
"Global seed and run number are not default; using the non-default values seed: " <<
354 virtual void DoRun (
void);
358 :
TestCaseBase (
"Uniform Random Variable Stream Generator")
364 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
368 gsl_histogram_set_ranges_uniform (h, 0., 1.);
373 gsl_histogram_free (h);
383 double confidence = 0.99;
384 double maxStatistic = gsl_cdf_chisq_Pinv (confidence, (
N_BINS - 1));
385 NS_LOG_DEBUG (
"Chi square required at " << confidence <<
" confidence for " <<
N_BINS <<
" bins is " << maxStatistic);
387 double result = maxStatistic;
389 for (uint32_t i = 0; i <
N_RUNS; ++i)
394 if (result < maxStatistic)
418 value =
x->GetValue ();
424 static const uint32_t UNIFORM_INTEGER_MIN {0};
425 static const uint32_t UNIFORM_INTEGER_MAX {4294967295U};
428 intValue =
x->GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN);
431 intValue =
x->GetInteger (UNIFORM_INTEGER_MAX, UNIFORM_INTEGER_MAX);
435 for (
int i = 0; i < 20; i++)
437 intValue +=
x->GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MIN + 1);
443 for (
int i = 0; i < 20; i++)
445 intValue =
x->GetInteger (UNIFORM_INTEGER_MAX - 1, UNIFORM_INTEGER_MAX);
446 if (intValue == UNIFORM_INTEGER_MAX)
454 intValue =
x->GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
455 uint32_t intValue2 =
x->GetInteger (UNIFORM_INTEGER_MIN, UNIFORM_INTEGER_MAX);
475 virtual void DoRun (
void);
479 :
TestCaseBase (
"Antithetic Uniform Random Variable Stream Generator")
485 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
489 gsl_histogram_set_ranges_uniform (h, 0., 1.);
494 gsl_histogram_free (h);
506 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
528 value =
x->GetValue ();
546 virtual void DoRun (
void);
553 :
TestCaseBase (
"Constant Random Variable Stream Generator")
592 virtual void DoRun (
void);
599 :
TestCaseBase (
"Sequential Random Variable Stream Generator")
651 virtual void DoRun (
void);
658 :
TestCaseBase (
"Normal Random Variable Stream Generator")
664 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
667 std::vector<double> expected (
N_BINS);
674 for (std::size_t i = 0; i <
N_BINS; ++i)
676 expected[i] = gsl_cdf_gaussian_P (range[i + 1], sigma) - gsl_cdf_gaussian_P (range[i], sigma);
681 gsl_histogram_free (h);
692 auto rng = generator.Create ();
695 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
699 double variance = 2.0;
711 double expectedMean = mean;
712 double expectedRms = mean / std::sqrt (variance *
N_MEASUREMENTS);
732 virtual void DoRun (
void);
739 :
TestCaseBase (
"Antithetic Normal Random Variable Stream Generator")
745 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
748 std::vector<double> expected (
N_BINS);
755 for (std::size_t i = 0; i <
N_BINS; ++i)
757 expected[i] = gsl_cdf_gaussian_P (range[i + 1], sigma) - gsl_cdf_gaussian_P (range[i], sigma);
763 gsl_histogram_free (h);
775 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
779 double variance = 2.0;
794 double expectedMean = mean;
795 double expectedRms = mean / std::sqrt (variance *
N_MEASUREMENTS);
815 virtual void DoRun (
void);
822 :
TestCaseBase (
"Exponential Random Variable Stream Generator")
828 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
831 std::vector<double> expected (
N_BINS);
837 for (std::size_t i = 0; i <
N_BINS; ++i)
839 expected[i] = gsl_cdf_exponential_P (range[i + 1], mu) - gsl_cdf_exponential_P (range[i], mu);
845 gsl_histogram_free (h);
857 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
870 double expectedMean = mean;
891 virtual void DoRun (
void);
898 :
TestCaseBase (
"Antithetic Exponential Random Variable Stream Generator")
904 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
907 std::vector<double> expected (
N_BINS);
913 for (std::size_t i = 0; i <
N_BINS; ++i)
915 expected[i] = gsl_cdf_exponential_P (range[i + 1], mu) - gsl_cdf_exponential_P (range[i], mu);
921 gsl_histogram_free (h);
933 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
949 double expectedMean = mean;
970 virtual void DoRun (
void);
980 :
TestCaseBase (
"Pareto Random Variable Stream Generator")
986 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
989 std::vector<double> expected (
N_BINS);
994 for (std::size_t i = 0; i <
N_BINS; ++i)
996 expected[i] = gsl_cdf_pareto_P (range[i + 1], shape, scale) - gsl_cdf_pareto_P (range[i], shape, scale);
1002 gsl_histogram_free (h);
1014 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1037 double expectedMean = (shape * scale) / (shape - 1.0);
1057 virtual void DoRun (
void);
1067 :
TestCaseBase (
"Antithetic Pareto Random Variable Stream Generator")
1073 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1076 std::vector<double> expected (
N_BINS);
1081 for (std::size_t i = 0; i <
N_BINS; ++i)
1083 expected[i] = gsl_cdf_pareto_P (range[i + 1], shape, scale) - gsl_cdf_pareto_P (range[i], shape, scale);
1089 gsl_histogram_free (h);
1101 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1128 double expectedMean = (shape * scale) / (shape - 1.0);
1148 virtual void DoRun (
void);
1158 :
TestCaseBase (
"Weibull Random Variable Stream Generator")
1164 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1167 std::vector<double> expected (
N_BINS);
1175 for (std::size_t i = 0; i <
N_BINS; ++i)
1177 expected[i] = gsl_cdf_weibull_P (range[i + 1], a, b) - gsl_cdf_weibull_P (range[i], a, b);
1184 gsl_histogram_free (h);
1196 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1232 double expectedMean = scale;
1252 virtual void DoRun (
void);
1262 :
TestCaseBase (
"Antithetic Weibull Random Variable Stream Generator")
1268 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1271 std::vector<double> expected (
N_BINS);
1279 for (std::size_t i = 0; i <
N_BINS; ++i)
1281 expected[i] = gsl_cdf_weibull_P (range[i + 1], a, b) - gsl_cdf_weibull_P (range[i], a, b);
1287 gsl_histogram_free (h);
1299 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1338 double expectedMean = scale;
1358 virtual void DoRun (
void);
1368 :
TestCaseBase (
"Log-Normal Random Variable Stream Generator")
1374 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1377 std::vector<double> expected (
N_BINS);
1385 for (std::size_t i = 0; i <
N_BINS; ++i)
1387 expected[i] = gsl_cdf_lognormal_P (range[i + 1], mu, sigma) - gsl_cdf_lognormal_P (range[i], mu, sigma);
1393 gsl_histogram_free (h);
1405 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1427 double expectedMean = std::exp (mu + sigma * sigma / 2.0);
1454 virtual void DoRun (
void);
1464 :
TestCaseBase (
"Antithetic Log-Normal Random Variable Stream Generator")
1470 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1473 std::vector<double> expected (
N_BINS);
1481 for (std::size_t i = 0; i <
N_BINS; ++i)
1483 expected[i] = gsl_cdf_lognormal_P (range[i + 1], mu, sigma) - gsl_cdf_lognormal_P (range[i], mu, sigma);
1489 gsl_histogram_free (h);
1501 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1525 double expectedMean = std::exp (mu + sigma * sigma / 2.0);
1552 virtual void DoRun (
void);
1562 :
TestCaseBase (
"Gamma Random Variable Stream Generator")
1568 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1571 std::vector<double> expected (
N_BINS);
1579 for (std::size_t i = 0; i <
N_BINS; ++i)
1581 expected[i] = gsl_cdf_gamma_P (range[i + 1],
alpha, beta) - gsl_cdf_gamma_P (range[i],
alpha, beta);
1587 gsl_histogram_free (h);
1599 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1618 double expectedMean =
alpha * beta;
1638 virtual void DoRun (
void);
1648 :
TestCaseBase (
"Antithetic Gamma Random Variable Stream Generator")
1654 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1657 std::vector<double> expected (
N_BINS);
1665 for (std::size_t i = 0; i <
N_BINS; ++i)
1667 expected[i] = gsl_cdf_gamma_P (range[i + 1],
alpha, beta) - gsl_cdf_gamma_P (range[i],
alpha, beta);
1673 gsl_histogram_free (h);
1685 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1708 double expectedMean =
alpha * beta;
1728 virtual void DoRun (
void);
1738 :
TestCaseBase (
"Erlang Random Variable Stream Generator")
1744 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1747 std::vector<double> expected (
N_BINS);
1753 double lambda = 1.0;
1758 for (std::size_t i = 0; i <
N_BINS; ++i)
1760 expected[i] = gsl_cdf_gamma_P (range[i + 1], k, lambda) - gsl_cdf_gamma_P (range[i], k, lambda);
1766 gsl_histogram_free (h);
1778 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1782 double lambda = 2.0;
1797 double expectedMean = k * lambda;
1817 virtual void DoRun (
void);
1827 :
TestCaseBase (
"Antithetic Erlang Random Variable Stream Generator")
1833 gsl_histogram * h = gsl_histogram_alloc (
N_BINS);
1836 std::vector<double> expected (
N_BINS);
1842 double lambda = 1.0;
1847 for (std::size_t i = 0; i <
N_BINS; ++i)
1849 expected[i] = gsl_cdf_gamma_P (range[i + 1], k, lambda) - gsl_cdf_gamma_P (range[i], k, lambda);
1855 gsl_histogram_free (h);
1867 double maxStatistic = gsl_cdf_chisq_Qinv (0.05,
N_BINS);
1871 double lambda = 2.0;
1890 double expectedMean = k * lambda;
1907 virtual void DoRun (
void);
1917 :
TestCaseBase (
"Zipf Random Variable Stream Generator")
1965 double expectedMean = 1.0;
1982 virtual void DoRun (
void);
1992 :
TestCaseBase (
"Antithetic Zipf Random Variable Stream Generator")
2043 double expectedMean = 1.0;
2060 virtual void DoRun (
void);
2070 :
TestCaseBase (
"Zeta Random Variable Stream Generator")
2100 double expectedMean =
2101 gsl_sf_zeta_int (static_cast<int> (
alpha - 1)) /
2102 gsl_sf_zeta_int (static_cast<int> (
alpha) );
2119 virtual void DoRun (
void);
2129 :
TestCaseBase (
"Antithetic Zeta Random Variable Stream Generator")
2162 double expectedMean =
2163 gsl_sf_zeta_int (static_cast<int> (
alpha) - 1) /
2164 gsl_sf_zeta_int (static_cast<int> (
alpha) );
2181 virtual void DoRun (
void);
2188 :
TestCaseBase (
"Deterministic Random Variable Stream Generator")
2203 double array1 [] = { 4, 4, 7, 7, 10, 10};
2204 std::size_t count1 = 6;
2227 double array2 [] = { 1000, 2000, 3000, 4000};
2228 std::size_t count2 = 4;
2254 virtual void DoRun (
void);
2264 :
TestCaseBase (
"Empirical Random Variable Stream Generator")
2275 x->SetInterpolate (
false);
2277 x->CDF ( 5.0, 0.25);
2283 double value =
x->GetValue ();
2285 "Incorrect value returned, expected only 5 or 10.");
2301 double expectedMean = 8.75;
2306 x->SetInterpolate (
true);
2321 expectedMean = 6.25;
2346 virtual void DoRun (
void);
2356 :
TestCaseBase (
"EmpiricalAntithetic Random Variable Stream Generator")
2367 x->SetInterpolate (
false);
2369 x->CDF ( 5.0, 0.25);
2378 double value =
x->GetValue ();
2380 "Incorrect value returned, expected only 5 or 10.");
2387 double expectedMean = 8.75;
2391 x->SetInterpolate (
true);
2399 expectedMean = 6.25;
2416 virtual void DoRun (
void);
2420 :
TestCaseBase (
"NormalRandomVariable caching of parameters")
2430 double v1 =
n->GetValue (-10, 1, 10);
2431 double v2 =
n->GetValue (10, 1, 10);
2449 :
TestSuite (
"random-variable-stream-generators", UNIT)
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.
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.
A factory base class to create new instances of a random variable.
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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Test case for Weibull distribution random variable stream generator.
Test case for antithetic log-normal distribution random variable stream generator.
static const uint32_t N_BINS
Number of bins for sampling the distributions.
AttributeValue implementation for Boolean.
virtual double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
virtual void DoRun(void)
Implementation to actually run this TestCase.
double Average(Ptr< RandomVariableStream > rng) const
Compute the average of a random variable.
Test case for constant random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
ParetoAntitheticTestCase()
Hold variables of type string.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation.
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 constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Base class for RandomVariableStream test suites.
virtual void DoRun(void)
Implementation to actually run this TestCase.
ExponentialAntitheticTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Hold a signed integer type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool m_seedSet
true if we've already set the seed the correctly.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
EmpiricalAntitheticTestCase()
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.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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 constexpr double TOLERANCE
Tolerance for testing rng values against expectation.
virtual void DoRun(void)
Implementation to actually run this TestCase.
GammaAntitheticTestCase()
Test case for gamma distribution random variable stream generator.
static uint64_t GetRun(void)
Get the current run number.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
void SetValueArray(double *values, std::size_t length)
Sets the array of values that holds the predetermined sequence.
ErlangAntitheticTestCase()
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
Test case for normal distribution random variable stream generator.
Test case for Erlang distribution random variable stream generator.
virtual double GetValue(void)
Get the next random value as a double drawn from the distribution.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
virtual double GetValue(void)
Returns the next value in the sequence.
Test case for antithetic empirical distribution random variable stream generator. ...
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Factory class to create new instances of a particular random variable stream.
#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.
Test case for caching of Normal RV parameters (see issue #302)
void CDF(double v, double c)
Specifies a point in the empirical distribution.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
LogNormalAntitheticTestCase()
Test case for antithetic Erlang distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
virtual void DoRun(void)
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
#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...
Test case for log-normal distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
bool SetInterpolate(bool interpolate)
Switch the mode between sampling the CDF and interpolating.
virtual void DoRun(void)
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Test case for deterministic random variable stream generator.
static RandomVariableSuite randomVariableSuite
Test case for antithetic gamma distribution random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
virtual Ptr< RandomVariableStream > Create(void) const =0
Create a new instance of a random variable stream.
Test case for sequential random variable stream generator.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
Test case for Zipf distribution random variable stream generator.
virtual void DoRun(void)
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
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.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
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.
Test case for empirical distribution random variable stream generator.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
static uint32_t GetSeed(void)
Get the current seed value which will be used by all subsequently instantiated RandomVariableStream o...
void SetTestSuiteSeed(void)
Set the seed used for this test suite.
Test case for antithetic Pareto distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
static void SetSeed(uint32_t seed)
Set the seed.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
double max(double x, double y)
static const uint32_t N_MEASUREMENTS
Number of samples to draw when populating the distributions.
WeibullAntitheticTestCase()
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
Test case for antithetic Zipf distribution random variable stream generator.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
Test case for antithetic normal distribution random variable stream generator.
#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...
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
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.
Test case for Zeta distribution random variable stream generator.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Test case for antithetic Weibull distribution random variable stream generator.
TestCaseBase(std::string name)
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
RandomVariableStream test suite, covering all random number variable stream generator types...
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< RandomVariableStream > Create(void) const
Create a new instance of a random variable stream.
double min(double x, double y)
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...
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
virtual void DoRun(void)
Implementation to actually run this TestCase.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
static const uint32_t N_RUNS
Number of retry attempts to pass a chi-square test.
Test case for antithetic exponential distribution random variable stream generator.
NormalAntitheticTestCase()
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
bool m_anti
Whether to create antithetic random variable streams.
#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.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Test case for exponential distribution random variable stream generator.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Test case for antithetic Zeta distribution random variable stream generator.
RngGenerator(bool anti=false)
Constructor.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, as a fraction of mean value.
static constexpr double TOLERANCE
Tolerance for testing rng values against expectation, in rms.
double ChiSquaredTest(Ptr< RandomVariableStream > rng) const
Compute the chi square value from a random variable.
Test case for Pareto distribution random variable stream generator.
#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.