%I #18 Jul 08 2026 10:22:33
%S 2,3,4,0,1,5,6,2,3,4,0,1,2,7,5,3,2,4,0,1,8,3,2,6,4,0,1,2,5,3,4,2,0,1,
%T 3,9,2,5,4,6,0,1,3,2,7,4,2,3,0,1,5,2,4,3,0,1,2,6,5,3,4,2,0,1,10,3,2,4,
%U 7,0,1,2,5,3,6,4,2,0,1,3,8,2,4,5,0,1,3
%N A sequence constructed by greedily sampling the Hermite distribution, with both parameters as 1, to minimize discrepancy.
%C The distribution is given by the PDF p(k) = (Sum_{i=0..floor(k/2)} 1/(i!*(k-2*i)!)) / e^2 = 2F0([-k/2, (1-k)/2], [], 4) / (e^2 * k!). It has p(0)=p(1)=1/e^2 which is less than p(2). From p(2) onwards it is strictly decreasing.
%C The arithmetic mean approaches Sum_{k>=1} k * p(k) = 3 in the limit.
%H Jwalin Bhatt, <a href="/A394758/b394758.txt">Table of n, a(n) for n = 1..10000</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Hermite_distribution">Hermite distribution</a>.
%e Let p(k) denote the probability of k and c(k) denote the number of occurrences of k among the first n-1 terms; then the expected number of occurrences of k among n random terms is given by n*p(k).
%e We subtract the actual occurrences c(k) from the expected occurrences and pick the one with the highest value. In case of ties, pick the smallest k. Let f(k) = n*p(k) - c(k).
%e | n | f(0) | f(1) | f(2) | f(3) | f(4) | f(5) | choice |
%e |---|--------|--------|--------|--------|--------|--------|--------|
%e | 1 | 0.135 | 0.135 | 0.203 | - | - | - | 2 |
%e | 2 | 0.270 | 0.270 | -0.593 | 0.315 | - | - | 3 |
%e | 3 | 0.406 | 0.406 | -0.390 | -0.526 | 0.422 | - | 4 |
%e | 4 | 0.541 | 0.541 | -0.187 | -0.368 | -0.436 | 0.365 | 0 |
%e | 5 | -0.323 | 0.676 | 0.015 | -0.210 | -0.295 | 0.456 | 1 |
%e | 6 | -0.187 | -0.187 | 0.218 | -0.052 | -0.154 | 0.548 | 5 |
%t probCountDiff[j_, k_, count_]:= k*HypergeometricPFQ[{(1-j)/2, -j/2}, {}, 4]/(E^2*j!) - Lookup[count, j, 0]
%t samplePDF[n_] := Module[{coeffs, unreachedVal, counts, k, probCountDiffs, mostProbable},
%t coeffs = ConstantArray[0, n]; unreachedVal = 2; counts = <||>;
%t Do[probCountDiffs = Table[probCountDiff[i, k, counts], {i, 0, unreachedVal}];
%t mostProbable = Position[probCountDiffs, Max[probCountDiffs], {1}, 1][[1, 1]] - 1;
%t If[mostProbable == unreachedVal, unreachedVal++]; coeffs[[k]] = mostProbable;
%t counts[mostProbable] = Lookup[counts, mostProbable, 0] + 1, {k, 1, n}]; coeffs]
%t A394758 = samplePDF[120]
%o (Python)
%o from mpmath import iv
%o from math import factorial
%o def prob_count_diff(j, k, count):
%o hermite = sum((iv.mpf(1) / (factorial(i)*factorial(j-2*i))) for i in range(1+j//2)) / iv.exp(2)
%o return k*hermite - count
%o def sample_hermite_distribution(num_coeffs):
%o coeffs, unreached_val, counts = [], 2, {}
%o for k in range(1, num_coeffs+1):
%o prob_count_diffs = [prob_count_diff(i, k, counts.get(i, 0)) for i in range(unreached_val+1)]
%o most_probable = prob_count_diffs.index(max(prob_count_diffs))
%o unreached_val += most_probable == unreached_val
%o coeffs.append(most_probable)
%o counts[most_probable] = counts.get(most_probable, 0) + 1
%o return coeffs
%o A394758 = sample_hermite_distribution(120)
%Y Cf. A381617, A382961, A383899, A394562, A394733.
%K nonn,changed
%O 1,1
%A _Jwalin Bhatt_, Mar 31 2026