OFFSET
1,1
COMMENTS
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.
The arithmetic mean approaches Sum_{k>=1} k * p(k) = 3 in the limit.
LINKS
Jwalin Bhatt, Table of n, a(n) for n = 1..10000
Wikipedia, Hermite distribution.
EXAMPLE
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).
We subtract the actual occurrences c(k) from the expected occurrences and pick the one with the highest value. Let f(k) = n*p(k) - c(k).
| n | f(0) | f(1) | f(2) | f(3) | f(4) | f(5) | choice |
|---|--------|--------|--------|--------|--------|--------|--------|
| 1 | 0.135 | 0.135 | 0.203 | - | - | - | 2 |
| 2 | 0.270 | 0.270 | -0.593 | 0.315 | - | - | 3 |
| 3 | 0.406 | 0.406 | -0.390 | -0.526 | 0.422 | - | 4 |
| 4 | 0.541 | 0.541 | -0.187 | -0.368 | -0.436 | 0.365 | 0 |
| 5 | -0.323 | 0.676 | 0.015 | -0.210 | -0.295 | 0.456 | 1 |
| 6 | -0.187 | -0.187 | 0.218 | -0.052 | -0.154 | 0.548 | 5 |
MATHEMATICA
probCountDiff[j_, k_, count_]:= k*HypergeometricPFQ[{(1-j)/2, -j/2}, {}, 4]/(E^2*j!) - Lookup[count, j, 0]
samplePDF[n_] := Module[{coeffs, unreachedVal, counts, k, probCountDiffs, mostProbable},
coeffs = ConstantArray[0, n]; unreachedVal = 2; counts = <||>;
Do[probCountDiffs = Table[probCountDiff[i, k, counts], {i, 0, unreachedVal}];
mostProbable = Position[probCountDiffs, Max[probCountDiffs], {1}, 1][[1, 1]] - 1;
If[mostProbable == unreachedVal, unreachedVal++]; coeffs[[k]] = mostProbable;
counts[mostProbable] = Lookup[counts, mostProbable, 0] + 1, {k, 1, n}]; coeffs]
A394758 = samplePDF[120]
PROG
(Python)
from mpmath import iv
from math import factorial
def prob_count_diff(j, k, count):
hermite = sum((iv.mpf(1) / (factorial(i)*factorial(j-2*i))) for i in range(1+j//2)) / iv.exp(2)
return k*hermite - count
def sample_hermite_distribution(num_coeffs):
coeffs, unreached_val, counts = [], 2, {}
for k in range(1, num_coeffs+1):
prob_count_diffs = [prob_count_diff(i, k, counts.get(i, 0)) for i in range(unreached_val+1)]
most_probable = prob_count_diffs.index(max(prob_count_diffs))
unreached_val += most_probable == unreached_val
coeffs.append(most_probable)
counts[most_probable] = counts.get(most_probable, 0) + 1
return coeffs
A394758 = sample_hermite_distribution(120)
CROSSREFS
KEYWORD
nonn
AUTHOR
Jwalin Bhatt, Mar 31 2026
STATUS
approved
