On random number generators and practical market efficiency

Modern mainstream financial theory is underpinned by the efficient market hypothesis, which posits the rapid incorporation of relevant information into asset pricing. Limited prior studies in the operational research literature have investigated tests designed for random number generators to check for these informational efficiencies. Treating binary daily returns as a hardware random number generator analogue, tests of overlapping permutations have indicated that these time series feature idiosyncratic recurrent patterns. Contrary to prior studies, we split our analysis into two streams at the annual and company level, and investigate longer-term efficiency over a larger time frame for Nasdaq-listed public companies to diminish the effects of trading noise and allow the market to realistically digest new information. Our results demonstrate that information efficiency varies across years and reflects large-scale market impacts such as financial crises. We also show the proximity to results of a well-tested pseudo-random number generator, discuss the distinction between theoretical and practical market efficiency, and find that the statistical qualification of stock-separated returns in support of the efficient market hypothesis is dependent on the driving factor of small inefficient subsets that skew market assessments.


Introduction
One of the primary constituents of financial research is the efficient market hypothesis, which, depending on its variation, prohibits the possibility of significant forecasting based on different kinds of data due to the sufficiently fast incorporation of available information into asset prices (Fama, 1965(Fama, , 1970)).It is, in some settings, linked to the hypothesis that markets are inherently unpredictable due to following random walks to varying degrees, effectively viewing financial time series as martingales or submartingales (Kendall and Hill, 1953;Cootner, 1964;Malkiel, 1973).
Randomised algorithms employing a random number generator (RNG) are ubiquitous in research applications, including fields as diverse as politics, biology, and cosmology (see, for example, Carson and Lubensky, 2009;Chaudhary et al., 2014;Moews et al., 2019a).The most common application area is, of course, cryptography, as encryptions that underlie electronic communication protocols and, by extension, the Internet, rely on hard-to-predict pseudo-RNGs (C ¸avuşoglu et al., 2016).
Given these security challenges, there was an early desire to develop statistical tests for randomness, most famously the Diehard Battery of Tests, which contains the overlapping permutations test applicable to binary sequences (Marsaglia and Tsang, 2002).
In the literature on financial machine learning, a common way to approach challenges into a two-class forecasting problem is to transform datasets to a binary representation (Fischer and Krauss, 2018;Lee et al., 2019;Moews et al., 2019b).When doing so in a way that removes known market features such as heteroskedasticity, meaning a lack of variance homogeneity along the evolution of a given time series, we can pose the question whether tests assessing the quality of RNGs can then be applied to investigations of market efficiency.
The collection of prior research features two works covering this point of view, both in the operational research literature.
First, Doyle and Chen (2013) introduce the application of the overlapping permutations test to the efficient market hypothesis in an exploratory study, analysing daily closing prices for 76 broad exchange indices and finding non-uniformity of changes in returns for a subset of them.
Explicitly building on the latter study, Noakes and Rajaratnam (2016) then focus on the Johannesburg Stock Exchange to investigate the efficiency of small, mid, and large market capitalisation indices over the 2005-2019 period.They extend the mentioned prior research by including adjustments for thin trading, meaning periods of no or low trading volumes, due to the same use of daily price series, and find more evidence for inefficiency among indices for companies with small market capitalisations.
In this paper, we confirm the viability of crossdisciplinary methodology transfers, from the field of random number generation to econometrics, bridging the gap through the application of operational research to the study of financial markets.We combine the strengths of the two existing studies in the literature by focussing on a single exchange generally considered to be efficient in the financial literature, and spanning a both larger and more recent time frame.We also make use of both monthly and daily returns, deviating from previous works by studying market efficiency over longer time horizons made available for information incorporation.
The further contributions of this paper are fourfold and go beyond the scope of the above-mentioned prior research.First, we investigate two sets of experiments, one separated by years and one by companies, to quantify variations in efficiency for both variables, and verify considerable annual variations.We challenge the latter finding with an analysis of cross-correlation systematics through monthly distributional sums, in which the impact of the recent global financial crisis can be observed.
Next, we compare both types of experiments to a state-of-the-art pseudo-RNG as a baseline for the overlapping permutations test, and find that companyseparated tests show statistically significant inefficiencies by a slim margin, while year-separated tests paint a clearer picture of a lack of market efficiency.We then consider the role of a small subset of inefficiently traded outliers, demonstrating that company-separated return series fully qualify for randomness under the given test with only a small percentage of companies omitted, and put this finding in the context of prior results.
Lastly, we discuss the notions of theoretical and practical market efficiency as well as consequences of the former, and describe the sufficiency of our results for the latter.Our results have implications for the application of cryptographic tests in financial research, the evolution of weak-form inefficiency as an anomaly on volatile exchanges in developed markets, and the study of exchange inefficiency on the firm level.

Information efficiency in financial markets
As one of the cornerstones of modern financial theory, the efficient market hypothesis (EMH) makes statements about the incorporation of relevant information into stock prices.Initially proposed by Fama (1965), it branches into three major variations: • The strong form states that asset prices reflect all information, both public and private, due to a timely incorporation by market participants.
• The semi-strong form relaxes this position and states the above only for publicly available information, allowing for profitable insider trading.
• The weak form, in a further constriction, posits that asset prices reflect past stock market information such as prices and trading volumes.
The weak-form EMH is of special interest for us, as it concerns the incorporation of past information regarding stock behaviour into the market, as opposed to newly emerging information such as earnings announcements.
The latter can, due to the randomness of unpredictable new information, be viewed as noise injections into the market in the context of time series of returns, whereas past stock information should not have a significant impact on future market performance under the umbrella of all forms.While the prior literature on the topic of this paper does not cover market efficiency beyond the above, it is useful to provide a short overview.Fama (1970) frames the hypothesis in terms of expected returns, with p i,t as the price of a given security i at time t, and accordingly for p i,t+1 , whereas r i,t denotes the return percentage, meaning r i,t = (p i,t+1 − p i,t )/p i,t .Φ t represents information assumed to be incorporated into p i,t , and the tilde operator signifies the role as a random variable.This formulation, despite its widespread adoption in financial economics, has not met universal approval.An early criticism is made shortly after by LeRoy (1976), who describes the definitions used in Fama (1970) as tautologies, an assessment repeated later as "[...] applying a conditional expectations operator to the identity defining the rate of return as equal to the price relative p t+1 /p t (less one)."(LeRoy, 1989).Following Fama (1970), the position that p i,t fully reflects Φ t then implies that The same holds for returns, meaning This is generally referred to as a "fair game" with respect to the available information by Fama (1970).As for Equation 1, LeRoy (1989) criticises that these equations follow from the definitions of α i,t+1 and β i,t+1 with expectations conditional on Φ t on both sides, and argues that the former two definitions as fair game variables do not restrict the stochastic process of the price.The implication is that any capital market would be efficient, while no empirical data could decide on market efficiency.Later alternatives to these definitions include the reference to a true price model for assessing equilibrium values available to market agents, although this is acknowledged to introduce a joint hypothesis problem by Fama (1991), and these definitions continue to face criticisms as tautological (Pilkington, 2016).While the purpose of this section is a short-form overview of the background and equations commonly encountered, these objections should be kept in mind when assessing the literature, and reviews from different perspectives are available to the interested reader (Malkiel, 2005;LeRoy, 2010;Ausloss et al., 2016).Under the assumption that the time series of prices {p i,t } follows a submartingale.
Interpreting market efficiency as the independence of successive returns, an additional assumption can be made, which is their identical distribution.This leads, as conditional and marginal probability distributions of independent random variables are identical, to for a density function f that is invariant to t.While widely accepted in mainstream financial theory, the EMH has attracted criticisms from the field of behavioural economics early on, for example by Nicholson (1968), and the general counterargument can be summarised as the doubtful statement that, maybe, people are not quite as rational as the mathematical maximisation of utility functions seems to imply (DellaVigna, 2009).These criticisms from a behavioural perspective persist until today, with a recent review available in Kapoor and Prosad (2017).
In more recent times, the field has further expanded into findings from neuroscience, with corresponding attacks on orthodox market efficiency (Ardalan, 2018).Despite this, the hypothesis has proven to possess explanatory power, thus cementing its place in the literature, and the results in this paper paint a picture of explicable variations rather than its rejection from a practical perspective.
While this section targets a limited overview, one alternative is of special interest in the discussion of Section 4 and warrants a short introduction due to its place between the EMH and behavioural criticisms mentioned above.Introduced by Lo (2004) the adaptive market hypothesis aims to reconcile the dominant notion of market efficiency with the findings of behavioural finance from an evolutionary perspective.
Contrary to the assumption that market forces are strong enough to overcome behavioural biases in aggregate, this alternative argues based on bounded rationality as pioneered by Simon (1955), as opposed to the axiom of rational expectations.Using this framework's assumption of "satisficing", the adoption of satisfactory choices due to the costs and limitations of human decisionmaking, the latter is explained through heuristics that are developed and adapted in an evolutionary learning process.
Should market circumstances change, maladaptive heuristics grow to be unfit, and market actors' behaviour needs to change to remain competitive.Changes in market efficiency in this context can be described, in simple terms, as markets being more efficient if many market agent "species" compete for limited financial opportunity resources, as opposed to few species competing for abundant resources.
The adaptive market hypothesis has found empirical success in the analysis of United States stock markets (Urquhart and McGroarty, 2014).Other studies from the last few years cover European and Asiant markets, as well as cryptocurrency exchanges.(Urquhart and McGroarty, 2016;Chu et al., 2019;Xiong et al., 2019).A recent overview for the interested reader can be found in Lo (2017).With this short primer covered, we can now think about the implications for binarised series of stock market returns and their relationship to random number generation.

Exchange and empirical data description
We retrieve monthly close prices of Nasdaq-listed stocks, spanning the years 2001-2019, from the Wharton Research Data Services (WRDS) Compustat database.It also features, despite a smaller total market capitalisation, more companies than the New York Stock Exchange, and is subject to considerably higher year-to-year volatility.The latter is especially interesting for analyses comparing annual differences in informational efficiency, which is why we opt for this exchange as a data source.
This provides us with a dataset featuring 809,195 entries for 4,905 companies, with associated company identifiers and dates.Missing values are a challenge commonly encountered in financial data, and have to be dealt with either through omission of affected entries or imputation methods.While the latter, despite their widespread use, are sometimes cautioned against, for example by Kofman and Sharpe (2003), the problem that we would encounter in our analysis is more fundamental: We are, as Section 2.4 will detail in a bit, interested in the distribution of binary patterns, and the content of missing sections can be entirely unrelated to the pattern of missing entries, for example due to data collection issues stemming from technical difficulties limited to certain periods.As the question how these subtly changing binary patterns should be imputed is difficult to answer satisfactorily, we drop companies that feature missing monthly close prices within the time frame covered by the dataset.This leads to the omission of 417 companies, or approximately 8.50%, and is followed by a further cleaning step that drops companies that feature less than a year's worth of entries, resulting in another 5.86% being sorted out, which is acceptable given that we investigate efficiency across the exchange and on the company level.
Figure 1 shows the number of entries per year, tracing the evolution of companies featured on the exchange over time, with dashed and solid lines indicating the dataset before and after the preprocessing, respectively.Aside from the increasing number of Nasdaq-listed public companies, two features stick out.The first is the slowing of growth around 2008, which can be explained by the impact of the Global Financial Crisis of 2007-2008 on IPOs (Aktas et al., 2019).
The second is the bump around 2005, which shows a slight decrease, and is mostly visible in the dataset before preprocessing.Natural explanations for this deviation include aftershocks of the Dotcom Bubble's burst a few years prior as well as the privatisation effect of the Sarbanes-Oxley Act in the United States following a series of corporate and accounting scandals, which regulates financial reporting and report keeping for public companies.This wave of privatisations for formerly public companies is demonstrated in the literature, for example by Engel and Wang (2007).
The effect on efficiency is still debated, as described in an overview by Bai et al. (2016), although this is combined with a reported lack of empirical evidence for disclosure legislation leading to breaks in market informativeness.As our approach studies market efficiency regardless of contributing factors, this is not of direct concern, but our analysis shows an improvement in month-to-month efficiency for the year said act was passed, lasting until the Global Financial Crisis of 2007-2008.

Data preprocessing and considerations
WRDS Compustat, as described in Section 2.2, provides both cumulative adjustment factors and total return factors for the purpose of price adjustment for any given time period, with the former being a ratio that enables per-share prices to be adjusted for all stock splits and dividends occurring subsequent to the end of a given period.Similarly, the latter represents a multiplication factor that includes cash-equivalent distributions along with reinvestment of dividends, as well as the compounding effect of dividends paid on reinvested dividends.Following the database's guidelines, we compute adjusted close prices from unadjusted prices pi,t , and for δ i,t and γ i,t as the cumulative adjustment factor and the total return factor, respectively, as In the next step, we calculate the return by computing the natural logarithm of the price ratio between the current and prior period for given price series of length N , Here, the logarithm takes the fact into account that individual stocks' price changes are partially dependent on price magnitudes (Karpoff, 1987).In order to visualise the relevance of working with returns instead of prices, Figure 2 shows recurrence plots for a random sample of companies from the dataset, with a recurrence plot R n,m for horizontal and vertical axes n and m generally being calculated as where − → v is a phase space trajectory, ǫ is a binarisation threshold, and Θ is the Heaviside step function.
Recurrence plots are frequently used in both statistics and chaos theory to image the periodic nature of phase space trajectories, meaning similar areas being visited in such a space.More informally and in our case, it shows the distance between points along a time series, omitting the binarisation and visualising recurrences as times a trajectory returns to a previous value.
The first row of the figure, corresponding to a trajectory − → p i , shows slightly darkened upper-left and lower-right corners in the first row indicating slow adiabatic changes in line with the framing of market efficiency as a random walk with drift by Fama (1970).As we can see, raw prices are less than ideal in terms of their homogeneity, and the calculation of logarithmic returns in the second row generally alleviates these problems.In the final step, we binarise the return series using the median řt , The choice of the median over the arithmetic mean follows Doyle and Chen ( 2013), as this option yields equal numbers of ones and zeroes in the resulting binary array, with an offset of one for uneven lengths.This binarisation also takes care of heteroskedasticity as the lack of variance homogeneity along the evolution of a given time series, which corresponds to return volatility in our case.The presence of heteroskedasticity in markets is well-known in both the financial and operational research literature (Mandelbrot and Taylor, 1967;Lamoureux and Lastrapes, 1990;Fabozzi et al., 2017;Meligkotsidou et al., 2019).Lastly, another well-known effect in financial time series is momentum, meaning positive autocorrelation, which is generally described as a premier anomaly of the EMH (Fama, 1970).Financial research sometimes uses "runs tests" to check for unbroken sequences of upward or downward movements, which struggle to find oscillations between positive and negative autocorrelations, as they cancel each other out.The overlapping permutations test described in the following Section 2.4 is not subject to this shortcoming, and also able to check for patterns beyond such unbroken sequences.

Overlapping permutations to test randomness
Originally developed as the generalised serial test by Good and Gover (1967), this approach is based on a small number of earlier works considering the use of permutations to assess randomness (Kendall and Smith, 1938;Bartlett, 1951;Good, 1953).It tests for the equiprobability of k ν separate ν-nomes, or permutations of length ν, for k possible letters, and later found entry into the Diehard Battery of Tests for RNGs, here it is still one of the recommended core constituents of today's As an interesting anecdote, Irving J. Good served alongside Alan Turing at Bletchley Park during WWII, and later also was a consultant for Stanley Kubrick's science fiction classic "2001: A Space Odyssey".
testing suites for pseudo-RNGs (Marsaglia and Tsang, 2002;Luengo and Villalba, 2021).In its binary variation, we set k = 2 and calculate, in an analogy to χ 2 for multinomial distributions, as the expectation for the frequency of each unique pattern under the assumption of uniformity.As Ψ 2 ν does not have an asymptotic tabular χ 2 distribution due to a violation of the assumption of independence caused by the overlap of windows, Good and Gover (1967) propose first differences to alleviate this problem as This statistic fulfils an asymptotic tabular χ 2 distribution; and taking the second difference also fulfils asymptotic independence, meaning that we can calculate with as the associated degrees of freedom for ν ≥ 2. While the difference of one in separate ψ 2 ν values in the case of uneven array lengths from Section 2.3 gives rise to the question of the impact, most terms cancel out in sums over ∇ 2 ψ 2 ν , as shown by Doyle and Chen (2013).Following the prior literature, we make use of ν ∈ {1, 2, . . ., 8} in our tests, and rely on the second differences due to its improved suitability for testing for uniform randomness (Marsaglia, 2005).10, with lighter shades of grey corresponding to higher values for the window size.

Tests of monthly information incorporation
In the first step, we calculate ψ 2 ν values for our dataset, split into two experimental streams for company-separated and year-separated arrays, respectively.As we are dealing with a set of 4,225 company-associated stocks, summary statistics are computed for these measurements.The upper part of Table 1 shows these results on a companyseparated level, listing the arithmetic mean and standard deviation for window sizes ν ∈ {1, 2, . . ., 8}.In addition, as large-valued subsets will become relevant further down, the table also shows the respective maximum per window size.
Results for ν = 1 correspond to the measurement of single binary values, and are expectedly slightly larger than for subsequent year-level experiments due to the smaller average array length for monthly entries over the investigated time frame.
Next, we repeat the same experiment with entries separated by their year, leading to the results listed in the lower part of Table 1.As opposed to the companyseparated case, 19 entries easily lend themselves to being listed individually in a table, in addition to the summary statistics already used before.The ψ 2 ν values paint a very diverse picture in terms of the year-to-year volatility of measured pattern retrieval, with both higher means and maxima.In part, this can be explained by the possibility of patterns occurring within the constraints of a given annual time frame, whereas company-separated measurements spanning the entire time period of the dataset offer an avenue to even these pattern distributions out.
While the means in the upper part of Table 1 closely trace the values reported by Doyle and Chen (2013) for the Nasdaq Composite index, validating both the implementation and the stability of these analyses over different time frames, year-to-year analyses paint a different picture.Given these findings, the question arises whether different window sizes correlate in terms of these results.
We plot ψ 2 ν values for window sizes ν ∈ {1, 2, . . ., 8} in Figure 3 to see how indicators for the presence of recurring patterns relate to different pattern lengths.The plot demonstrates mostly strong co-movements across window sizes, steering us towards the notion that when patterns of one size are recurring above uniformity, so are those corresponding to other window sizes.
In the next step, we calculate second differences as per Equation 12, again for both company-separated and yearseparated datasets.Given the mathematical guarantees of ∇ 2 ψ 2 ν values outlined in Section 2.4 and further described by Good and Gover (1967), we can now make use of critical χ 2 values for given degrees of freedom at the commonly employed 5% level for statistical significance.Second differences that fail to meet this threshold, thus not supporting the discarding of the null hypothesis of uniform randomness, are indicated in bold.
The upper part of Table 2 shows results for companyseparated data.Interestingly, while the arithmetic means indicate uniform randomness, the combined χ 2 values for multiplied degrees of freedom of |A| × ξ ν , for lengths of given arrays A, do not share this result.This leads us to the suspicion that there are small subsets of highly inefficient stocks that skew the sums upwards, which is further supported by the calculation of proportions of a The calculation of ψ 2 ν follows Equation 10.
statistically significant measures in the table.
We confirm this effect by dropping sufficiently small percentages of the highest contributors and reevaluating the measures for combined χ 2 values.When doing so, it is important to readjust critical χ 2 values to account for the slightly reduced array sizes.The fourth to penultimate rows in the upper part of Table 2 demonstrate how small percentages (1%, 2%, 3%) result in statistical insignificance for the combined χ 2 values for different window sizes, starting with ν = 3, 5, 6 for 1%.We extend the coverage by ν = 4, 8 for 2%, and finally add ν = 7 for 3%, bringing the sums in line with the arithmetic means in terms of their support for uniform randomness.
Next, in the lower part of Table 2, we repeat the same measures for the year-separated dataset as for ψ 2 ν values before in the lower part of Table 1.We see, just like for the company-separated results, statistically significant deviations from uniform randomness in the arithmetic means, which we have now established to be due to small subsets of companies with pattern-heavy stock behaviour.This results, when viewing measures at the annual level, in a high proportion of significant results, although these statistics vary starkly between years and demonstrate annual variations in market efficiency as measured through recurring patterns in this paper.
Finally, as a complementary visualisation, we transform each year's array into its constituent months to separate stocks, and plot kernel density estimates of the resulting array sums in Figure 4.This translates to each column-wise sum being a count of ones per month and year, where uniformly-random distributions would approximate a narrow distribution around the mean.The horizontal axis is scaled based on array lengths to maintain comparability, and distributions are centred around the mean indicated by a solid vertical line.While not a perfect approximation by any means, the evolution of the count spreads roughly follows the time series in Figure 3, including a broad distribution corresponding to increased intra-market cross-correlations during the Global Financial Crisis of 2007-2008(Zheng et al., 2012)).

Comparison to measurements of daily data
In contrast to Doyle and Chen (2013) and Noakes and Rajaratnam (2016), who perform analyses on 76 and 111 time series, respectively, our analysis covers the entire exchange and operate on 4,905 instruments as described in Section 2.2.While this makes the use of monthly instead of daily close prices a natural choice, the computational expense to repeat our analysis for daily time steps, which brings the ν values for monthly data of Nasdaq-listed companies in the 2001-2019 time frame, as well as the combined χ 2 statistic.The upper part shows results for data separated by company, as well as combined χ 2 statistics for percentual omissions of the highest contributors.The lower part shows results for data separated by year, as well as ∇ 2 ψ 2 ν values for each year.Results failing the threshold for significance at the 5% level are indicated in bold.a number of entries from 809,195 to 18,832,546, is beneficial as a comparison.Consequently, we obtain daily close prices for the same stocks and years, and repeat our experiments to test for statistically significant deviations from uniform randomness.Table 3 shows the results of this additional analysis.Measurements for the arithmetic means and standard deviations for company-separated data stay almost identical to both our monthly results and Doyle and Chen (2013)'s values for the Nasdaq Composite, demonstrating the broad consistency of our results for different time frames.One interesting difference to our previous results is the dropping of the highest 5% of inefficient contributors to achieve statistically significant measurements of efficiency across all degrees of freedom.
Given the smaller time steps, more stocks have a chance to contribute highly inefficient periods to the overall result, which is confirmed by the listed higher shares of inefficient contributors for degrees of freedom requiring additional percentages to be dropped.While not unexpected, this provides a useful insight into the slight differences that data granularity can have on analyses.One difference of particular interest is the clear concentration of inefficiency for higher degrees versus lower degrees of freedom, which indicates shorter non-random patterns being more spread out across instruments for daily data.Similarly, the results for the year-separated dataset repeat the previously observed deviations from uniform randomness in the arithmetic means, and the stronger presence of an inefficient subset leads to a relative elevation in year-to-year measurements.
Taking into account the known differences in market  , 4, 8, 16, 32, 64}, the mean and standard deviation for ∇ 2 ψ 2 ν values for daily data of Nasdaq-listed companies in the 2001-2019 time frame, as well as the combined χ 2 statistic.The upper part shows results for data separated by company, as well as combined χ 2 statistics for percentual omissions of the highest contributors.The lower part shows results for data separated by year, as well as ∇ 2 ψ 2 ν values for each year.Results failing the threshold for significance at the 5% level are indicated in bold.a efficiency in favour of longer time scales (see, for example, Kim and Shamsuddin, 2008;Rodriguez et al., 2014), monthly and daily close prices reasonably mirror each other in terms of the overall findings and implications.This first application of the approach used in our experiments to varying data frequencies encourages the analysis of different time frames in related works, which we touch upon in Section 4.

Comparison to pseudo-random numbers
When assessing the findings of the previous sections, a natural question is that of measurements one would expect from a uniformly-random distribution.This allows for a direct comparison to numerical results for our methodology that represent the case of the null hypothesis, and well-established pseudo-RNGs can be used as a baseline in our study's context of markets as an RNG analogue.
In terms of broader applications in programming languages, the MT19937 implementation of the Mersenne Twister algorithm has long been the a standard pseudo-RNG since its original inception as an answer to then-current flaws in older generators (Matsumoto and Nishimura, 1998).In more recent years, however, other general-purpose algorithms have been developed and begun to supplant its reign.
One example is the family of permuted congruential generators (PCG) introduced by O'Neill (2014).The a The calculation of ψ 2 ν follows Equation 10.
Table 5: Results for second differences for increasing degrees of freedom.The table shows, for degrees of freedom ξ ∈ {2, 4, 8, 16, 32, 64}, summary statistics for ∇ 2 ψ 2 ν values across generated pseudo-random numbers.Rows 1-4 and rows 5-8 cover a set modelled on the yearseparated and firm-separated dataset, respectively.Results failing the threshold for significance at the 5% level are marked in bold.a PCG64 implementation found widespread adoption, and was made the default generator used by the NumPy mathematical library as of version 1.17 in 2019.Among the reasons for this adoption are the passing of the TestU01 suite with zero failures, which distinguishes it from the Mersenne Twister algorithm as the prior default (L'Ecuyer and Simard, 2007).
Using the PCG64 implementation to repeat our experiments from Section 3.1, Table 4 shows that the means for ψ 2 ν are very close to those for firm-separated values in the upper part of Table 1, with slightly higher standard deviations, while both means and standard deviations are notably lower for the year-separated dataset.
In both cases, the respective maxima are considerably lower than those for the empirical Nasdaq data, underlining the previously noted impact of inefficient subsets.
For second differences ∇ 2 ψ 2 ν , Table 5 shows the same statistical metrics as before, for firm-separated values, as the lower part of Table 2.We can see that both arithmetic means and combined χ 2 measures retain the null hypothesis of uniform randomness across all degrees of freedom, setting the pseudo-RNG apart from our market analogue.We also tested a simplistic pseudo-RNG based on logistic maps with iterative seed draws to confirm the overlapping permutations test's ability to pick up on weak pseudo-RNGs.The sums in particular often barely qualify or fail the test for uniform randomness, highlighting the need for well-tested generators for comparative purposes.
Results for company-separated data closely trace each other for empirical data and pseudo-RNG simulations, with marginally larger means and standard deviations for the former, and with means across both experiments maintaining the null hypothesis of uniformly-random data for all window sizes.The same holds true for combined χ 2 measures once the subset of high-impact contributors are removed, as described in Section 3.1.The proportion of statistically significant measures is also approximately the same for company-level Nasdaq data and pseudo-RNG simulations.
Contrary to that, year-separated experiments differ prominently between empirical and simulated data; means and standard deviations taken over annual measures are considerably larger than for the pseudo-RNG output.The latter also features a proportion of statistically significant results similar to the company-separated simulation, whereas the empirical dataset consists mostly of instances satisfying the criterion for inefficiency.As shown in Section 3, a small number of stocks not filtered out in a year-by-year analysis drives much of these large values, although that specific impact does not explain the stark variability between years, with mostly years before the recent global financial crisis qualifying for market efficiency for some of the window sizes.

Discussion
We have shown that there are significant year-to-year changes in exchange-wide efficiency, as well as an overall inefficiency in aggregated annual data.We also find that individual stocks of Nasdaq-listed companies are efficient in aggregate when taking small subsets of inefficient outliers into account, which offers a partial explanation of annual variability, and that stocks follow approximately the same level of uniformly-random assessment as welltested pseudo-RNGs.The last point is especially relevant to annual anomalies, as they can both be driven by inefficient subsets and be resolved in terms of efficiency over longer time frames, placing the market in a state of overall efficiency at a larger scale.While we have adjusted monthly and daily close prices for splits and dividends as described in Section 2.3, experiments with unadjusted raw prices yield almost identical results.One area that warrants a closer look is the compatibility of our results with the concept of market efficiency in general.Samuelson (1973) formalises a random walk model of market efficiency, demonstrating both the martingale property of such a model and its allowance for subsets of market participants, too small to affect prices appreciably, to systematically realise excess returns.This is, of course, especially relevant in terms of stronger forms of market efficiency, for both fundamental analysis as permitted under the semi-strong EMH and strong-form insider trading.It also means that market data that is transformed into binarised returns can still contain hidden inefficiencies exploited by small pools of capital, drawing a line between the model of theoretical efficiency and the leeway that practical implementations allow.The result in terms of uniform randomness in empirical data, in both cases and as far as statistical analyses go, is the same.
This bears similarity to two different proposals in the literature; self-destruction of predictability as described by Timmermann and Granger (2004), which posits that anomaly exploitability decays due to a time-limited presence or public dissemination of the anomaly, and the adaptive market hypothesis by Lo (2004), which attempts to reconcile market efficiency with behavioural economics through adaption processes in changing market environments.
Research on the latter mentioned in Section 2.1 generally focusses on foreign investment, market microstructure factors, and calendar effects.In contrast, we propose an additional technological perspective on the market environment and market actor adaptability.New developments, be it in terms of computing resources or methodology, do not push adopted approaches to market participation out due to the transitory nature of exploitable anomalies or widespread adoption following publication.
Instead, the process is a result of a technological arms race that renders prior solutions unfit for the changed market environment.An already established and prominent example of this process is the competition in terms of information transmission speeds among highfrequency trading firms.In recent years, the adoption of modern machine learning among financial practitioners, as well as the fast development of new methods in the field, has provided further fuel (Gogas and Papadimitriou, 2021).However, as long as adopted technologies, or satisficing heuristics under the terminology of the adaptive market hypothesis, do not outperform to a degree that renders predecessors ineffective, small pools of capital, akin to a small number of species in an abundant environment, can exploit anomalies in a shared manner.
The above paragraphs show that for the effects of theoretical market efficiency to occur, at least on a meaningful level and for varying notions of market efficiency, the underlying process can contain complications related to inefficiency.This should not come as a surprise, as the EMH, just like models in other disciplines rooted in the scientific method, is a model with explanatory power that does, necessarily, allow for a certain degree of leeway to remain succinct.Anomalies detected in our experiments are, thus, reconcilable with practical market efficiency.
With regard to financial economics and econometrics, this paper provides valuable insights on the timedependent variability of weak-form market efficiency, as well as on the role of outliers in the assessment of overarching exchanges and broad indices.Natural followups to this type of investigation are the more finegrained analyses of flash crashes and financial crises, which Noakes and Rajaratnam (2016) already start for the impact of the Global Financial Crisis of [2007][2008] in South Africa, the potential for industry sector influences and similar effects that shape the presence and importance of inefficient subsets, and the measurement of differences between exchanges, both in terms of subset-driven inefficiency and annual variance, as well as regarding the impact of exchange volatility on overlapping permutations tests.
Similarly, in the field of market microstructure, the question arises whether the latter differences can be linked to exchange peculiarities such as trading rules, systems, and accessibility of advances in financial technology such as high-frequency trading.While our paper, due to limitations in its scope, follows Noakes and Rajaratnam (2016) in focussing on a particular exchange, a comparison to other developed markets, for example in Europe, is an interesting follow-up avenue (Borges, 2010).
In the same vein, and regarding the mentioned differences in trading environment and technology, emerging markets also warrant further study to extend this area of application (Gregoriou, 2009).Lastly, the same approach can be transferred to different types of markets outside of stock exchanges.Here, the efficiency of foreign exchange markets is a prime target for follow-up research as a long-standing topic of interest in the financial literature (Burt et al., 1977;Chaboud et al., 2014).As mentioned in Section 3.2, different time scales are an interesting extension to these kinds of studies, and varying efficiencies of foreign exchange markets for varying data granularity is an additional direction for future research.

Conclusion
This paper builds on and extends a topic that has recently developed in the operational research literature, centred on the application of overlapping permutations tests from the field of random number generation to financial exchanges, to test for informational efficiency in markets.To this end, we go beyond existing research by covering a larger and more recent time frame with longer step sizes, and by splitting our experiments into the company level and year-separated analyses for Nasdaq data.
Our results for company-separated data demonstrate that stocks of individual Nasdaq-listed public companies feature average market efficiency as measured in this study, although this efficiency is only confirmed when omitting a small subset of outliers, which skew the overall assessment towards statistically significant inefficiency for the overall exchange.This has implications for prior research on whole markets and overarching indices, and for hypothesis tests of market efficiency more generally.For daily instead of monthly close prices, the number of outliers is slightly larger, as shorter-term inefficiencies in price behaviour can contribute to the results, and this increase is driven by short patterns spanning only a few days.
When performing the same analysis on year-separated data instead, we find that the same effect applies, but also that assessments vary starkly in their pattern recurrence, which is further confirmed through the distribution of summed counts, and reflects cross-correlations and decreased efficiency during financial crisis scenarios.
For both streams, we perform comparisons to a well-tested pseudo-random number generator and find comparable measures for company-separated data once outliers are removed, while annual analyses differ in their year-to-year variation.We also discuss the implications of theoretical versus practical efficiency for market participants, arguing for the latter kind of efficiency to allow for adaptive leeway as well as unrealised inefficiencies while maintaining the results implied by financial theory.
Our work contributes to the literature on crossdisciplinary methodology transfers in operational research, applications of cryptographic tools in econometric analyses, the evolution of weak-form inefficiency as an anomaly on volatile exchanges in developed markets, and the broader study of exchange efficiency on the individual company level as well as differences between exchanges and links to market microstructure.

Figure 1 :
Figure 1: Data points per calendar year.The figure shows entries for monthly stock prices available for Nasdaq-listed companies covering the years 2001-2019.The dashed line indicates the full dataset, whereas the solid line denotes the dataset with the omission of companies that feature missing values for price entries.

Figure 2 :
Figure 2: Recurrence plots for stock prices and relative returns.Each column of the plot corresponds to one randomly sampled Nasdaq-listed company from a dataset covering the years 2001-2019.The first row shows recurrence plots for unprocessed stock prices, while the second row shows the same type of plot for logarithmic returns relative to the respective prior period's price for the same company.

Figure 3 :
Figure 3: Psi-square statistic per calendar year.The figure shows the evolution of ψ 2 values for Nasdaq-listed companies in the 2001-2019 time frame, with shifting window sizes ν ∈ {1, 2, . . ., 8}.The statistic follows Equation10, with lighter shades of grey corresponding to higher values for the window size.

Figure 4 :
Figure 4: Kernel density estimates of monthly variability.The figure shows the distribution of binarised monthly returns per year, reshaped into month-wise columns and summed over each column.

Table 1 :
Psi-square statistic per window size.The table shows, for window sizes ν ∈ {1, 2, . . ., 8}, the mean, standard deviation, and maximum for ψ 2 values for monthly data of Nasdaq-listed companies in the 2001-2019 time frame.The upper and lower parts show results for data separated by company and year, respectively, as well as ψ 2 values for each year.a

Table 3 :
Second difference for increasing degrees of freedom.The table shows, for degrees of freedom ξ ∈ {2