login
Given: 1. alphabet of 3 elements {x1,x2,x3}; 2. vector V of size L(V) = 10; Let w(x1) = number of failed trials before the last event x1. For all the possible configurations {w(x1),w(x2),w(x3)} admitted in vectors of L(V)=10, the sequence gives the number of vectors having the same configuration {w(x1),w(x2),w(x3)}.
1

%I #20 Apr 07 2014 11:36:53

%S 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

%T 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

%U 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,7,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7

%N Given: 1. alphabet of 3 elements {x1,x2,x3}; 2. vector V of size L(V) = 10; Let w(x1) = number of failed trials before the last event x1. For all the possible configurations {w(x1),w(x2),w(x3)} admitted in vectors of L(V)=10, the sequence gives the number of vectors having the same configuration {w(x1),w(x2),w(x3)}.

%H Cristian Mesiano, <a href="/A239700/b239700.txt">Table of n, a(n) for n = 1..3239</a>

%H Cristian Mesiano, <a href="http://textanddatamining.blogspot.ch/2014/03/coefficients-of-waiting-time.html">Coefficients of Waiting Time Polynomials: a nice representation</a>

%F a(n) = {i, j, k} : i + j + k = Z;

%F b(j) = P(A(j));

%F b(j, k,V) = i;

%F b(j, k,X) = j;

%F b(j, k,Y) = k;

%F for each b(j):

%F Sum[p_1^i*p_2^j*p_3^k[

%F Sum[q_V^(d - i)*q_X^(e - j)*q_Y^(g - k)*

%F Sum[((d - 1)!*Abs[e - d - 1]!)/((i - 1)!* f!*(d - i - f)!*(j - f - 1)!*(e - d - j + f)!), {f, j - Min[j, e - d], 1}],

%F {d, i, i + j + k - 2}, {e,Max[i + j, d], i + j + k - 1}, {g, i + j + k, i + j + k}]],

%F {i, 1, Z}, {j, 1, Z - i}, {k, 1, -i - j + Z}]

%F The series is obtained by taking the coefficients of the polynomials, sorted in lexicographic order, on the exponents of p_1, p_2, p_3.

%F EXAMPLE:

%F Z = 10;

%F a(1)= {1, 1, 8}; a(2) = {1, 2, 7}; a(3)= {1, 3, 6};

%F b(2)= P(a(2)) = {{1, 2, 7}, {1, 7, 2}, {2, 1, 7}, {2, 7, 1}, {7, 1, 2}, {7, 2, 1}};

%F i = 1; j = 7; k = 2;

%F b(2,3)= {2, 1, 7};

%F b(2,3,V) = 1 -> V = 2;

%F b(2, 3,X) = 7 -> X = 3;

%F b(2, 3,Y) = 2 -> Y = 1;

%e Example:

%e alphabet = {a,b,c};

%e w(a)=7;

%e w(b)=5;

%e w(c)=5;

%e The number of vectors for which {w(a)=7,w(b)=5,w(c)=5}= 210.

%t getW[data_, p_] := Block[{p1, p1f, resq},

%t p1 = Position[data, p];

%t If[p1 == {}, Return[{{p, 0}, {p, 0}}]];

%t p1f = Flatten[p1];

%t resq = {#[[2]] - #[[1]] - 1} & /@ Partition[PrependTo[p1f, 1], 2, 1];

%t resq[[1]] += 1;

%t Return[{Select[Tally[data], #[[1]] == p &][[1]], {p,

%t Plus @@ Flatten[resq]}}]

%t ];

%t getMonomials[listOfVars_, dL_] := Block[{data, vars, coeff, res},

%t data = Tuples[listOfVars, dL];

%t vars =

%t Thread[{Table[Subscript[p, i], {i, 1, Length[listOfVars]}],

%t Table[Subscript[q, i], {i, 1, Length[listOfVars]}]}];

%t coeff =

%t Table[Thread[getW[data[[i]], #] & /@ listOfVars], {i, 1, Length[data]}];

%t coeff = #[[All, 2]] & /@ Thread[#] & /@ coeff;

%t res = Times @@ MapThread[Times, MapThread[Power, {vars, #}]] & /@ coeff;

%t Return[res];

%t ];

%t (*select monomials for which all the variables occur at least one time *)

%t SIZE = 10;

%t results =

%t Select[getMonomials[{v1, v2, v3},

%t SIZE], (Exponent[#, Subscript[p, 1]] >

%t 0) && (Exponent[#, Subscript[p, 2]] > 0) &&

%t Exponent[#, Subscript[p, 3]] > 0 &];

%t (*group monomials by same # events realization*)

%t results =

%t Gather[results, (Exponent[#1, Subscript[p, 1]] ==

%t Exponent[#2, Subscript[p, 1]]) && (Exponent[#1, Subscript[p, 2]] ==

%t Exponent[#2, Subscript[p, 2]]) && (Exponent[#1, Subscript[p, 3]] ==

%t Exponent[#2, Subscript[p, 3]]) &];

%t (*sort monomials by lexicographic order on event v1 and v2*)

%t results = {#[[1, 1 ;; 3]], #[[All, 4 ;; -1]]} & /@ results;

%t results = Reverse[Sort[results]];

%t (*polynomial*)

%t qVals = Plus @@ #[[2]] & /@ results;

%t (*get coefficients*)

%t coeff = Table[

%t If[IntegerQ[qVals[[i]][[j, 1]]] == True, qVals[[i]][[j, 1]], 1], {i, 1,

%t Length[qVals]}, {j, 1, Length[qVals[[i]]]}];

%K nonn

%O 1,94

%A _Cristian Mesiano_, Mar 24 2014