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.
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
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 |
Links
- Jwalin Bhatt, Table of n, a(n) for n = 1..25200
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)
Comments