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.
%I A386950 #25 Aug 24 2025 05:44:51 %S A386950 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, %T A386950 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, %U A386950 3,0,2,5,1,0,0,3,4,1,6,2,0,1,0,7,2,3,0 %N 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. %C A386950 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]. %C A386950 The respective probabilities are: %C A386950 p(0) = 7381/25200 = 0.292896... %C A386950 p(1) = 4861/25200 = 0.192896... %C A386950 p(2) = 3601/25200 = 0.142896... %C A386950 p(3) = 2761/25200 = 0.109563... %C A386950 p(4) = 2131/25200 = 0.084563... %C A386950 p(5) = 1627/25200 = 0.064563... %C A386950 p(6) = 1207/25200 = 0.047896... %C A386950 p(7) = 121/3600 = 0.033611... %C A386950 p(8) = 19/900 = 0.021111... %C A386950 p(9) = 1/100 = 0.01 %C A386950 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). %C A386950 The arithmetic mean of this sequence is 2.25. %C A386950 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... %H A386950 Jwalin Bhatt, <a href="/A386950/b386950.txt">Table of n, a(n) for n = 1..25200</a> %e A386950 Let p(k) denote the probability of k and c(k) denote the number of occurrences of k among the first n-1 terms. %e A386950 We take the ratio of the actual occurrences c(k)+1 to the probability and pick the one with the lowest value. %e A386950 Since p(k) is monotonic decreasing, we only need to compute c(k) once we see c(k-1). %e A386950 | n | (c(0)+1)/p(0) | (c(1)+1)/p(1) | (c(2)+1)/p(2) | choice | %e A386950 |---|---------------|---------------|---------------|--------| %e A386950 | 1 | 3.414 | - | - | 0 | %e A386950 | 2 | 6.828 | 5.181 | - | 1 | %e A386950 | 3 | 6.828 | 10.362 | 6.998 | 0 | %e A386950 | 4 | 10.242 | 10.362 | 6.998 | 2 | %t A386950 samplePDF[numCoeffs_] := Module[{coeffs, counts}, %t A386950 coeffs = {}; counts = ConstantArray[0, 10]; %t A386950 Do[ %t A386950 minTime = Infinity; %t A386950 Do[ %t A386950 time = 10*(counts[[i]] + 1)/(HarmonicNumber[10] - HarmonicNumber[i - 1]); %t A386950 If[time < minTime,minIndex = i;minTime = time],{i, 1, 10}]; %t A386950 counts[[minIndex]] += 1; %t A386950 coeffs = Append[coeffs, minIndex - 1], %t A386950 {numCoeffs} %t A386950 ]; %t A386950 coeffs %t A386950 ] %t A386950 A386950 = samplePDF[120] %o A386950 (Python) %o A386950 from sympy import harmonic %o A386950 def sample_pdf(num_coeffs): %o A386950 coeffs, counts = [], [0]*10 %o A386950 for _ in range(num_coeffs): %o A386950 min_time = float('inf') %o A386950 for i, count in enumerate(counts): %o A386950 time = 10*(count+1) / (harmonic(10)-harmonic(i)) %o A386950 if time < min_time: %o A386950 min_index, min_time = i, time %o A386950 counts[min_index] += 1 %o A386950 coeffs.append(min_index) %o A386950 return coeffs %o A386950 A386950 = sample_pdf(120) %Y A386950 Cf. A081528. %K A386950 nonn,base,new %O A386950 1,4 %A A386950 _Jwalin Bhatt_, Aug 10 2025