cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A386950 A sequence constructed by greedily sampling the pdf (H(10)-H(i))/10, where H(n) is the n-th Harmonic number and the support is [0,9], to minimize discrepancy.

Original entry on oeis.org

0, 1, 0, 2, 3, 0, 1, 4, 0, 2, 5, 1, 0, 3, 0, 1, 6, 2, 4, 0, 1, 0, 3, 2, 7, 0, 5, 1, 0, 2, 4, 1, 3, 0, 0, 1, 6, 2, 0, 3, 5, 1, 4, 8, 0, 2, 0, 1, 0, 3, 2, 1, 0, 4, 7, 0, 5, 1, 6, 2, 3, 0, 1, 0, 2, 4, 0, 1, 3, 0, 2, 5, 1, 0, 0, 3, 4, 1, 6, 2, 0, 1, 0, 7, 2, 3, 0
Offset: 1

Views

Author

Jwalin Bhatt, Aug 10 2025

Keywords

Comments

The pdf of the sequence is the probability to see i as the remainder when you divide 1,2,3... with a random number from [1,10].
The respective probabilities are:
p(0) = 7381/25200 = 0.292896...
p(1) = 4861/25200 = 0.192896...
p(2) = 3601/25200 = 0.142896...
p(3) = 2761/25200 = 0.109563...
p(4) = 2131/25200 = 0.084563...
p(5) = 1627/25200 = 0.064563...
p(6) = 1207/25200 = 0.047896...
p(7) = 121/3600 = 0.033611...
p(8) = 19/900 = 0.021111...
p(9) = 1/100 = 0.01
The sequence repeats after 25200 terms. If the random number is picked from [1,n] the period of the sequence is given by n*lcm{1,2,...,n} (A081528).
The arithmetic mean of this sequence is 2.25.
For a sequence with length n, the n-th root of the product of nonzero terms is (2**(5333/12600))*(3**(559/3150))*(5**(1627/25200))*(7**(121/3600)) which is 1.9302557640832...

Examples

			Let p(k) denote the probability of k and c(k) denote the number of occurrences of k among the first n-1 terms.
We take the ratio of the actual occurrences c(k)+1 to the probability and pick the one with the lowest value.
Since p(k) is monotonic decreasing, we only need to compute c(k) once we see c(k-1).
| n | (c(0)+1)/p(0) | (c(1)+1)/p(1) | (c(2)+1)/p(2) | choice |
|---|---------------|---------------|---------------|--------|
| 1 |     3.414     |       -       |       -       |   0    |
| 2 |     6.828     |     5.181     |       -       |   1    |
| 3 |     6.828     |    10.362     |     6.998     |   0    |
| 4 |    10.242     |    10.362     |     6.998     |   2    |
		

Crossrefs

Cf. A081528.

Programs

  • Mathematica
    samplePDF[numCoeffs_] := Module[{coeffs, counts},
      coeffs = {}; counts = ConstantArray[0, 10];
      Do[
        minTime = Infinity;
        Do[
          time = 10*(counts[[i]] + 1)/(HarmonicNumber[10] - HarmonicNumber[i - 1]);
          If[time < minTime,minIndex = i;minTime = time],{i, 1, 10}];
        counts[[minIndex]] += 1;
        coeffs = Append[coeffs, minIndex - 1],
        {numCoeffs}
       ];
      coeffs
     ]
    A386950 = samplePDF[120]
  • Python
    from sympy import harmonic
    def sample_pdf(num_coeffs):
      coeffs, counts = [], [0]*10
      for _ in range(num_coeffs):
        min_time = float('inf')
        for i, count in enumerate(counts):
          time = 10*(count+1) / (harmonic(10)-harmonic(i))
          if time < min_time:
            min_index, min_time = i, time
        counts[min_index] += 1
        coeffs.append(min_index)
      return coeffs
    A386950 = sample_pdf(120)