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-3 of 3 results.

A371761 Array read by antidiagonals: The number of parades with n girls and k boys that begin with a girl and end with a boy.

Original entry on oeis.org

1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 5, 1, 0, 0, 1, 13, 13, 1, 0, 0, 1, 29, 73, 29, 1, 0, 0, 1, 61, 301, 301, 61, 1, 0, 0, 1, 125, 1081, 2069, 1081, 125, 1, 0, 0, 1, 253, 3613, 11581, 11581, 3613, 253, 1, 0, 0, 1, 509, 11593, 57749, 95401, 57749, 11593, 509, 1, 0
Offset: 0

Views

Author

Peter Luschny, Apr 05 2024

Keywords

Comments

The name derives from a proposition by Donald Knuth, who describes the setup of a "girls and boys parade" as follows: "There are m girls {g_1, ..., g_m} and n boys {b_1, ..., b_n}, where g_i is younger than g_{i+1} and b_j is younger than b_{j+1}, but we know nothing about the relative ages of g_i and b_j. In how many ways can they all line up in a sequence such that no girl is directly preceded by an older girl and no boy is directly preceded by an older boy?" [Our notation: A <- D, n <- m, k <- n].
In A344920, the Worpitzky transform is defined as a sequence-to-sequence transformation WT := A -> B, where B(n) = Sum_{k=0..n} A163626(n, k)*A(k). (If A(n) = 1/(n + 1) then B(n) are the Bernoulli numbers (with B(1) = 1/2.)) The rows of the array are the Worpitzky transforms of the powers up to the sign (-1)^k.
The array rows are recursively generated by applying the Akiyama-Tanigawa algorithm to the powers (see the Python implementation below). In this way the array becomes the image of A004248 under the AT-transformation when applied to the rows of A004248. This makes the array closely linked to A344499, which is generated in the same way, but applied to the columns of A004248.
Conjecture: Row n + 1 is row 2^n in table A136301, where a probabilistic interpretation is given (see the link to Parsonnet's paper below).

Examples

			Array starts:
[0] 1, 0,   0,     0,      0,       0,        0,         0,          0, ...
[1] 0, 1,   1,     1,      1,       1,        1,         1,          1, ...
[2] 0, 1,   5,    13,     29,      61,      125,       253,        509, ...
[3] 0, 1,  13,    73,    301,    1081,     3613,     11593,      36301, ...
[4] 0, 1,  29,   301,   2069,   11581,    57749,    268381,    1191989, ...
[5] 0, 1,  61,  1081,  11581,   95401,   673261,   4306681,   25794781, ...
[6] 0, 1, 125,  3613,  57749,  673261,  6487445,  55213453,  431525429, ...
[7] 0, 1, 253, 11593, 268381, 4306681, 55213453, 610093513, 6077248381, ...
.
Seen as triangle T(n, k) = A(n - k, k):
  [0] 1;
  [1] 0, 0;
  [2] 0, 1,  0;
  [3] 0, 1,  1,   0;
  [4] 0, 1,  5,   1,   0;
  [5] 0, 1, 13,  13,   1,  0;
  [6] 0, 1, 29,  73,  29,  1, 0;
  [7] 0, 1, 61, 301, 301, 61, 1, 0;
.
A(n, k) as sum of powers:
  A(2, k) =  -3+   2*2^k;
  A(3, k) =   7-  12*2^k+    6*3^k;
  A(4, k) = -15+  50*2^k-   60*3^k+   24*4^k;
  A(5, k) =  31- 180*2^k+  390*3^k-  360*4^k+  120*5^k;
  A(6, k) = -63+ 602*2^k- 2100*3^k+ 3360*4^k- 2520*5^k+  720*6^k;
  A(7, k) = 127-1932*2^k+10206*3^k-25200*4^k+31920*5^k-20160*6^k+5040*7^k;
		

Crossrefs

Variant: A272644.
Rows include: A344920 (row 2, signed), A006230 (row 3).
Row sums of triangle (n>=2): A297195, alternating row sums: A226158.
Diagonal of array: A048144.

Programs

  • Maple
    egf := 1/(exp(w) + exp(z) - exp(w + z)): serw := n -> series(egf, w, n + 1):
    # Returns row n (>= 0) with length len (> 0):
    R := n -> len -> local k;
    seq(k!*coeff(series(n!*coeff(serw(n), w, n), z, len), z, k), k = 0..len - 1):
    seq(lprint(R(n)(9)), n = 0..7);
    # Explicit with Stirling2 :
    A := (n, k) -> local j; add(j!^2*Stirling2(n, j)*Stirling2(k, j), j = 0..min(n, k)): seq(lprint(seq(A(n, k), k = 0..8)), n = 0..7);
    # Using the unsigned Worpitzky transform.
    WT := (a, len) -> local n, k;
    seq(add((-1)^(n - k)*k!*Stirling2(n + 1, k + 1)*a(k), k=0..n), n = 0..len-1):
    Arow := n -> WT(x -> x^n, 8): seq(lprint(Arow(n)), n = 0..8);
    # Two recurrences:
    A := proc(n, k) option remember; local j; if k = 0 then return k^n fi;
    add(binomial(n, j)*(A(n-j, k-1) + A(n-j+1, k-1)), j = 1..n) end:
    A := proc(n, k) option remember; local j; if n = 0 then 0^k else
    add(binomial(k + `if`(j=0,0,1), j+1)*A(n-1, k-j), j = 0..k) fi end:
  • Mathematica
    (* Using the unsigned Worpitzky transform. *)
    Unprotect[Power]; Power[0, 0] = 1;
    W[n_, k_] := (-1)^(n - k) k! StirlingS2[n + 1, k + 1];
    WT[a_, len_] := Table[Sum[W[n, k] a[k], {k, 0, n}], {n, 0, len-1}];
    A371761row[n_, len_] := WT[#^n &, len];
    Table[A371761row[n, 9], {n, 0, 8}] // MatrixForm
    (* Row n >= 1 by linear recurrence: *)
    RowByLRec[n_, len_] := LinearRecurrence[Table[-StirlingS1[n+1, n+1-k], {k, 1, n}],
    A371761row[n, n+1], len]; Table[RowByLRec[n, 9], {n, 1, 8}] // MatrixForm
  • Python
    from functools import cache
    from math import comb as binomial
    @cache
    def A(n, k):
        if n == 0: return int(k == 0)
        return sum(binomial(k + int(j > 0), j + 1) * A(n - 1, k - j)
               for j in range(k + 1))
    for n in range(8): print([A(n, k) for k in range(8)])
    
  • Python
    # The Akiyama-Tanigawa algorithm for powers generates the rows.
    def ATPowList(n, len):
        A = [0] * len
        R = [0] * len
        for k in range(len):
            R[k] = k**n   # Changing this to R[k] = (n + 1)**k generates A344499.
            for j in range(k, 0, -1):
                R[j - 1] = j * (R[j] - R[j - 1])
            A[k] = R[0]
        return A
    for n in range(8): print([n], ATPowList(n, 9))
  • SageMath
    def A371761(n, k): return sum((-1)^(j - k) * factorial(j) * stirling_number2(k + 1, j + 1) * j^n for j in range(k + 1))
    for n in range(9): print([A371761(n, k) for k in range(8)])
    

Formula

A(n, k) = k! * [z^k] (n! * [w^n] 1/(exp(w) + exp(z) - exp(w + z))).
A(n, k) = k! * [w^k] (Sum_{j=0..n} A075263(n, n - j) * exp(j*w)).
A(n, k) = Sum_{j=0..k} (-1)^(j-k) * Stirling2(k + 1, j + 1) * j! * j^n.
A(n, k) = Sum_{j=0..min(n,k)} (j!)^2 * Stirling2(n, j) * Stirling2(k, j).
A(n, k) = Sum_{j=0..n} (-1)^(n-j)*A028246(n, j) * j^k; this is explicit:
A(n, k) = Sum_{j=0..n} Sum_{m=0..n} binomial(n-m, n-j) * Eulerian1(n, m) * j^k *(-1)^(n-j), where Eulerian1 = A173018.
A(n, k) = Sum_{j=0..k} binomial(k + [j>0], j+1)*A(n-1, k-j) for n > 0.
A(n, k) = Sum_{j=1..n} binomial(n, j)*(A(n-j, k-1) + A(n-j+1, k-1)) for n,k >= 1.
Row n (>=1) satisfies a linear recurrence:
A(n, k) = -Sum_{j=1..n} Stirling1(n + 1, n + 1 - j)*A(n, k - j) if k > n.
A(n, k) = [x^k] (Sum_{j=0..n} A371762(n, j)*x^j) / (Sum_{j=0..n} Stirling1(n + 1, n + 1 - j)*x^j).
A(n, k) = A(k, n). (From the symmetry of the bivariate exponential g.f.)
Let T(n, k) = A(n - k, k) and G(n) = Sum_{k=0..n} (-1)^k*T(n, k) the alternating row sums of the triangle. Then G(n) = (n + 2)*Euler(n + 1, 1) and as shifted Genocchi numbers G(n) = -2*(n + 2)*PolyLog(-n - 1, -1) = -A226158(n + 2).

A006230 Bitriangular permutations.

Original entry on oeis.org

1, 13, 73, 301, 1081, 3613, 11593, 36301, 111961, 342013, 1038313, 3139501, 9467641, 28501213, 85700233, 257493901, 773268121, 2321377213, 6967277353, 20908123501, 62736953401, 188236026013, 564758409673, 1694375892301, 5083329003481, 15250389663613
Offset: 4

Views

Author

Keywords

Comments

Prepending the term 0 and setting the offset to 0 makes this sequence row 3 of A371761. In this form it can be generated by the Akiyama-Tanigawa algorithm for powers (see the Python script). - Peter Luschny, Apr 12 2024

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A136301 (row 4), A371761 (row 3).

Programs

  • Maple
    A006230:=-(z+1)*(6*z+1)/(z-1)/(3*z-1)/(2*z-1); # Conjectured by Simon Plouffe in his 1992 dissertation.
  • Mathematica
    12*StirlingS2[n+1, 3]+1; (* Brian Parsonnet, Feb 25 2011 *)
    Sum[ StirlingS2[n,i] * StirlingS2[ 3,i ] * i!^2, {i,3} ]; (* alternative, Brian Parsonnet, Feb 25 2011 *)
  • PARI
    Vec(x^4*(1 + x)*(1 + 6*x) / ((1 - x)*(1 - 2*x)*(1 - 3*x)) + O(x^40))
    \\ Colin Barker, Dec 27 2017
    
  • Python
    # Using the Akiyama-Tanigawa algorithm for powers from A371761.
    print(ATPowList(3, 27))  # Peter Luschny, Apr 12 2024

Formula

a(n) = 12*S(n-2) + 1, with S(n)=A000392(n) the Stirling numbers of second kind, 3rd column. - Ralf Stephan, Jul 07 2003
a(n+3) = Sum_{i=1..3} A008277(n,i) * A008277(3,i) * i!^2. - Brian Parsonnet, Feb 25 2011
From Colin Barker, Dec 27 2017: (Start)
G.f.: x^4*(1 + x)*(1 + 6*x) / ((1 - x)*(1 - 2*x)*(1 - 3*x)).
a(n) = 12*(3 - 3*2^(n-2) + 3^(n-2))/6 + 1.
a(n) = 6*a(n-1) - 11*a(n-2) + 6*a(n-3) for n>6. (End)

A136300 Numerator of ratio (the denominator being (n-1)!^2 = A001044(n-1)) giving the probability that the last of n persons drawing names randomly from a set of names draws their own, given that each person previously has drawn in succession and did not keep their own name. (Probability of derangements when allocated / rejected sequentially.)

Original entry on oeis.org

1, 0, 1, 5, 76, 1624, 52116, 2298708, 133929216, 9961180416, 921248743680, 103715841415680, 13967643016085760, 2217449301162071040, 409861043056032503040, 87262626872384643052800, 21202798521768886355558400, 5831660090586059239329792000, 1802587564536011525042697830400
Offset: 1

Views

Author

Brian Parsonnet, Mar 22 2008

Keywords

Comments

In "Secret Santa", if a person picks their own name, they pick another name and they throw their own name back in. If the last person draws their own name, there's a problem. What is that probability as a function of the number of people participating?

Examples

			If there is one person, the chance of the last person getting their own name is 100%, or 1 over 0!^2. For 2 people, it is 0 / 1!^2. For 3 people, it is 1 / 2!^2, creating a more interesting case. The possible drawings are {2,1,3}, {2,3,1} and {3,1,2}. All other drawings can't happen because the name is rejected and redrawn. But these 3 outcomes don't have equal probability, rather, they are 25%, 25% and 50% respectively. The first outcome is the only one in which the last person draws their own name. The first person has a 50% chance of drawing a 2 or 3. If 2, the second person has a 50% chance of drawing 1 or 3, for a total outcome probability of 1/4. Similarly with 4 people, the chance is 5/36, followed by 76/576 for 5 people, etc. For the case of 5 people, the above equations boil down to this end calculation: {1,5,2,1} * {12,8,9,6} summed, or 12 + 40 + 18 + 6 = 76.
		

Crossrefs

The sequence frequency table (sFreq) is A136301.

Programs

  • Mathematica
    maxP = 22;
    rows = Range[1, 2^(nP = maxP - 3)];
    pasc = Table[
       Binomial[p + 1, i] - If[i >= p, 1, 0], {p, nP}, {i, 0, p}];
    sFreq = Table[0, {maxP - 1}, {2^nP}]; sFreq[[2 ;; maxP - 1, 1]] = 1;
    For[p = 1, p <= nP, p++,
      For[s = 1, s <= p, s++, rS = Range[2^(s - 1) + 1, 2^s];
            sFreq[[p + 2, rS]] = pasc[[p + 1 - s, 1 ;; p + 2 - s]] .
                sFreq[[s ;; p + 1, 1 ;; 2^(s - 1)]]]];
    sProb = Table[p + 2 - BitGet[rows - 1, p - 1], {p, nP}];
    sProb = Table[Product[sProb[[i]], {i, p}], {p, nP}]*
       Table[If[r <= 2^p, 1, 0],
             {p, nP}, {r, rows}];
    rslt = Flatten[
      Prepend[Table[sProb[[p]] . sFreq[[p + 2]], {p, nP}], {1, 0, 1}]]
    prob = N[rslt/Array[(#1 - 1)!^2 & , maxP]] (* Brian Parsonnet, Feb 22 2011 *)

Formula

Sum of H(i, N-2) * X(i, N-2) for i=0..2^(N-3), N is the number of people and H(r,c) = sum of H(T(r),L(r)+j) * M(c-T(r)-1,j) for j = 0..c-L(r)-1 and X(r,c) = product of (3 + k - b(r,k)) for k = 0..(c-2) and M(y,z) = binomial distribution (y,z) when y - 1 > z and (y,z)-1 when (y-1)<=z and b(r,k) = bit k of r in base 2 and T(r) = A053645 and L(r) = A000523.
a(n) = (n-1)!*A102262(n)/A102263(n) for n > 1.

Extensions

Corrected and extended to a(19) by Brian Parsonnet, Feb 22 2011
Showing 1-3 of 3 results.