![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Von Neumann ratio test for randomness of a sequence. More...
#include <cmath>#include <cstddef>#include <vector>#include "line/api/sim/sim_dist.h"#include "line/api/sim/sim_types.h"#include "line/num/number.h"#include "line/util/error.h"Go to the source code of this file.
Classes | |
| struct | line::sim::VonNeumannResult< T > |
| Outcome of the von Neumann randomness test. More... | |
Namespaces | |
| namespace | line |
| namespace | line::sim |
Functions | |
| template<class T> | |
| VonNeumannResult< T > | line::sim::sim_vonneumann (const std::vector< T > &x, double alpha=0.05) |
| Von Neumann ratio test for randomness of a sequence. | |
Von Neumann ratio test for randomness of a sequence.
Port of matlab/src/api/sim/sim_vonneumann.m. The statistic is the ratio of the mean square successive difference to the variance, ratio = sum_{i=1}^{b-1} (x_{i+1}-x_i)^2 / sum_{i=1}^{b} (x_i - xbar)^2, with b the number of observations. Under the null hypothesis that x is i.i.d. normal the ratio has mean 2 and variance 4(b-2)/((b-1)(b+1)), and (ratio-2)/sd is asymptotically standard normal, so the two-sided p-value is 2(1-Phi(|z|)). Serial correlation of either sign moves the ratio away from 2: positive correlation shrinks the successive differences and pushes the ratio below 2, negative correlation pushes it above.
The null mean and variance above were confirmed by Monte Carlo over b = 10, 16, 24, 32, 50 to within 0.3% in the reference.
The test is TWO-SIDED and its rejection is used as a stopping rule by the QUEST procedures, so alpha here is a stage significance (0.30 by default in sim_fquest, decaying during warmup) and not the interval's coverage level.
Reference: J. von Neumann, "Distribution of the Ratio of the Mean Square Successive Difference to the Variance", Ann. Math. Statist. 12(4), 1941; L. C. Young, "Randomness in Ordered Sequences", Ann. Math. Statist. 12, 1941.
Definition in file sim_vonneumann.h.