The law of iterated logarithm asserts that if $x_1,x_2,\dots$ are i.i.d $\cal N(0,1)$ random variables and $S_n=x_1+x_2+\cdots+x_n$, then $$\limsup_{n \to \infty} S_n/\sqrt {n \log \log n} = \sqrt 2, $$ almost surely.
Question: how to make numerical experiment to "confirm/illustrate " this law ?
It seems it is obvious how to make such numeric check, however when I am doing it I do not see theoretical result, it might be I am doing some mistake or there is some subtlety in choosing the numbers "n", size of sample, size of "cutoff", etc...
(Motivation look at some real-world data and look whether they satisfy similar laws.)
Here is how I am doing:
$lim sup$ is $lim_n sup_{m: n <= m < Inf } $ numerically we cannot analyze infinite data set $m: n <= m < Inf$, so we must choose some "cutoff": $sup_{m: n<= m <= cutoff }$.
Question: What should be the right choice for "cutoff" ?
I have tried to choose cutoff = 2n, 3n, 4n, 10n 100n , 1000n that does not seem to work. It seems when I increase cutoff result comes close to theory, however how big to take it ?
For example n = 1e5, cutOff = 2*n; sampleNum = 1e3 I get .38 instead of sqrt(2)
for n = 1e5, cutOff = 3*n; sampleNum = 1e3 I get .49
for n = 1e5, cutOff = 4*n; sampleNum = 1e3 I get .56
for n = 1e5, cutOff = 5*n; sampleNum = 1e3 I get .58
for n = 1e5, cutOff = 10*n; sampleNum = 1e3 I get .67
for n = 1e4 cutOff = 100*n sampleNum = 1e3 I get .94
for n = 1e4 cutOff = 1000*n sampleNum = 1e2 I get 1
The code in matlab:
n = 1e5
cutOff = 5*n;
sampleNum = 1e3
for k=1:sampleNum
vecRandomN01 = randn(1,cutOff); % generate N(0,1) Y_i
vecSummation = cumsum(vecRandomN01); % generate S_n = sum_{i<=n} Yi
vecNormalizer = sqrt(n:cutOff).*sqrt(log(log(n:cutOff))); % Calculate denominator sqrt(n*log(log(n))) %
vecNormalizedData = vecSummation(n:cutOff) ./ vecNormalizer; % divide S_n / sqrt(n*log(log(n)))
vecStoreMax(k) = max(vecNormalizedData); % take maximum of S_m for "m: n<= m <= cutOff " %
% plot(vecNormalizedData); hold on;
end;
mean(vecStoreMax)
median(vecStoreMax)