# Testing for Benford Law in real time

Suppose I have data of a certain quantity $X$, given by $x_1,...,x_n$. Now, I take the first digit $d_i$ of each quantity $x_i$, and I want to study the relationship between the empirical distribution of first digits $\hat{p}=(\hat{p}_1,...,\hat{p}_n)$ where $\hat{p_i}$ is the normalized frequency of ocurrence of $i$ as the first digit, and benford's law $$p_i = \log_{10} (1 + 1/i)$$ Now, I've read this paper on the subject of comparing empirical frequencies of first digits vs benford's law. However, they don't mention whether the methods they mention can be used to be able to reject benford's law with a certain confidence in real time, where data arrive with a certain frequency (like, say, 50 data per second).

I think these methods can be applied to real time comparison with benford law in the following way: given a (small) interval of time (say, 3 seconds), we compute the empirical frecuencies of first digits $\hat{p}=(\hat{p}_1,...,\hat{p}_n)$ and then we compute the simultaneous confidence intervals and $p$-values of the statistics shown in the reference I mentioned previously (we have to make sure to have a sample size of at least 60 data, so that the distribution of the statistics should be relatively close to the asymptotic distributions, so the computed $p$-values should be reliable).

My question is, is this a valid procedure? Does it make sense? If not, is there some sound method for comparing empirical first digit distribution with benford law in real time?

One potential problem I see is that the underlying distribution of first digits may change in a given time window (perhaps even more than once). Which is why I think it is a good idea to use relatively small time windows, so as to have a decent sample size, while reducing the odds that the underlying distribution of first digits may change.

• +1 It's a good question--but the proposed procedure is invalid. Confidence intervals cannot be used for sequential tests; they will give too many false alarms.
– whuber
Sep 26, 2016 at 16:42
• @whuber thanks!. So I pressume goodness of fit tests would be invalid in this case as well, for the same reason? Sep 26, 2016 at 18:28
• Yes, I think that's right.
– whuber
Sep 26, 2016 at 19:07
• My initial intuition is that some kind of Bayesian approach would be most natural? Eg. Bayesian techniques were used by Jean Baptiste Eugène Estienne to test batches of ammunition while wasting fewer cartridges. Fewer wasted cartridges would loosely correspond to less time in your problem. Sep 26, 2016 at 22:53
• You may find some value in exploring sequential analysis, which relates to serial testing problems. Dec 8, 2019 at 8:08