login
A sequence constructed by greedily sampling the zeta distribution for parameter value 3 to minimize discrepancy.
2

%I #10 Jul 08 2026 18:12:19

%S 1,1,1,2,1,1,1,1,1,1,3,1,1,1,2,1,1,1,1,1,1,1,2,1,1,1,1,4,1,1,1,1,1,2,

%T 1,1,1,1,1,1,5,1,1,1,2,1,1,1,1,1,3,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,

%U 1,2,1,1,1,1,1,3,1,1,1,1,2,1,1,1,1,1,1

%N A sequence constructed by greedily sampling the zeta distribution for parameter value 3 to minimize discrepancy.

%C The probability mass function for this zeta distribution is given by p(i) = 1/(zeta(3)*i^3).

%C A general family of these distributions is given by p(i) = 1/(zeta(s)*i^s) where s > 1. This sequence is the s=3 case.

%C Properties change sharply at s=2, the geometric mean remains finite for all s but the arithmetic mean becomes finite for s > 2 and infinite for s <= 2.

%C | mean | 1 < s <= 2 | s > 2 |

%C | ---------- | ---------- | ------ |

%C | arithmetic | oo | finite |

%C | geometric | finite | finite |

%C The geometric mean approaches exp(-zeta'(3)/zeta(3)) = 1.1791840098089555... in the limit. In general, if the sequence was formed by every k^s occurrences, it would approach e^(-zeta'(s)/zeta(s)).

%C Unlike A381617, this sequence has a finite arithmetic mean, equal to zeta(2)/zeta(3) = 1.368432777... and in general for power s it equals zeta(s-1)/zeta(s).

%H Jwalin Bhatt, <a href="/A397557/b397557.txt">Table of n, a(n) for n = 1..10000</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Zeta_distribution">Zeta distribution</a>.

%e Let p(k) denote the probability of k and c(k) the number of occurrences of k among the first n-1 terms; the expected count among n terms is n*p(k). We pick the k maximizing n*p(k) - c(k).

%e | n | n*p(1) - c(1) | n*p(2) - c(2) | n*p(3) - c(3) | choice |

%e |---|---------------|---------------|---------------|--------|

%e | 1 | 0.831 | - | - | 1 |

%e | 2 | 0.663 | 0.207 | - | 1 |

%e | 3 | 0.495 | 0.311 | - | 1 |

%e | 4 | 0.327 | 0.415 | - | 2 |

%e | 5 | 1.159 | -0.480 | 0.154 | 1 |

%e | 6 | 0.991 | -0.376 | 0.184 | 1 |

%t probCountDiff[j_, k_, count_] := k/(Zeta[3] j^3) - Lookup[count, j, 0]

%t samplePDF[n_] := Module[{coeffs, unreachedVal, counts, k, probCountDiffs, mostProbable},

%t coeffs = ConstantArray[0, n]; unreachedVal = 1; counts = <||>;

%t Do[probCountDiffs = Table[probCountDiff[i, k, counts], {i, 1, unreachedVal}];

%t mostProbable = First@FirstPosition[probCountDiffs, Max[probCountDiffs]];

%t If[mostProbable == unreachedVal, unreachedVal++]; coeffs[[k]] = mostProbable;

%t counts[mostProbable] = Lookup[counts, mostProbable, 0] + 1, {k, 1, n}]; coeffs]

%t A397557 = samplePDF[87]

%o (Python)

%o from sympy import zeta

%o def prob_count_diff(j, k, count):

%o return k/(zeta(3)*j**3) - count

%o def sample_zeta_distribution(num_coeffs):

%o coeffs, unreached_val, counts = [], 1, {}

%o for k in range(1, num_coeffs+1):

%o diffs = [prob_count_diff(i, k, counts.get(i, 0)) for i in range(1, unreached_val+1)]

%o most_probable = diffs.index(max(diffs)) + 1

%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 A397557 = sample_zeta_distribution(87)

%Y Cf. A381522, A381617.

%K nonn,new

%O 1,4

%A _Jwalin Bhatt_, Jun 30 2026