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.

Showing 1-2 of 2 results.

A385685 Sequence where k is appended after every k! occurrences of 1, with multiple values following a 1 listed in order.

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 4, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 4, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3
Offset: 0

Views

Author

Jwalin Bhatt, Jul 06 2025

Keywords

Comments

The frequencies of the terms follow the Poisson distribution with parameter value 1.
The geometric mean approaches A385686 in the limit. In general, for parameter value p it approaches Product_{k>=2} k^(((p^(k-1))*((e-1)^(-p)))/k!).

Examples

			Every 1 is followed by a 1 because 1! = 1,
after every (2!=2) ones we see a 2,
after every (3!=6) ones we see a 3 and so on.
		

Crossrefs

Cf. A000142 (n!), A382093, A385686.

Programs

  • Mathematica
    A385685[n_] := Module[{N1 = 0,NR= 1, result = {},i=1}, While[Length[result] < n,N1++;AppendTo[result, 1]; Do[If[Mod[N1, Factorial[k]] == 0,    AppendTo[result, k];f[k == NR + 1, NR++]],{k, 2, NR + 1}];If[Length[result] > n, result = Take[result, n]]];result];A385685[92] (* James C. McMahon, Jul 11 2025 *)
  • Python
    from itertools import islice
    from math import factorial
    def poisson_distribution_generator():
        num_ones, num_reached = 0, 1
        while num_ones := num_ones+1:
            yield 1
            for num in range(2, num_reached+2):
                if num_ones % factorial(num) == 0:
                    yield num
                    num_reached += num == num_reached+1
    A385685 = list(islice(poisson_distribution_generator(), 120))

A385873 A sequence constructed by greedily sampling the Poisson distribution for parameter value 1 so as to minimize discrepancy.

Original entry on oeis.org

1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 4, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 1, 2, 1, 1, 3, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 5, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 4
Offset: 1

Views

Author

Jwalin Bhatt, Jul 11 2025

Keywords

Comments

The geometric mean approaches A385686 = exp((Sum_{k>=2} log(k)/k!)/(e-1)) in the limit.
The Poisson distribution used here is p(i) = 1/((e-1)*i!).

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; 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.
| n | n*p(1) - c(1) | n*p(2) - c(2) | n*p(3) - c(3) | choice |
|---|---------------|---------------|---------------|--------|
| 1 |     0.581     |     0.290     |     0.096     |   1    |
| 2 |     0.163     |     0.581     |     0.193     |   2    |
| 3 |     0.745     |    -0.127     |     0.290     |   1    |
| 4 |     0.327     |     0.163     |     0.387     |   3    |
| 5 |     0.909     |     0.454     |    -0.515     |   1    |
		

Crossrefs

Programs

  • Mathematica
    probCountDiff[j_, k_, count_]:=N[k/((E-1)*Factorial[j])]-Lookup[count, j, 0]
    samplePDF[n_]:=Module[{coeffs, unreachedVal, counts, k, probCountDiffs, mostProbable},
      coeffs=ConstantArray[0, n]; unreachedVal=1; counts=<||>;
      Do[probCountDiffs=Table[probCountDiff[i, k, counts], {i, 1, unreachedVal}];
        mostProbable=First@FirstPosition[probCountDiffs, Max[probCountDiffs]];
        If[mostProbable==unreachedVal, unreachedVal++]; coeffs[[k]]=mostProbable;
        counts[mostProbable]=Lookup[counts, mostProbable, 0]+1; , {k, 1, n}]; coeffs]
    A385873=samplePDF[120]
Showing 1-2 of 2 results.