Trinomial expansion

 

Let's take the following polynomial (which is closely related to the binomial expansion, and it is in fact a particular case of trinomial expansion):

(1+x+x2)n

It's expansion gives a series of coefficients, depending solely on n.

if n = 0,            1;
if n = 1,         1  1  1;
if n = 2,      1  2  3  2  1;
if n = 3,   1  3  6  7  6  3 1;
if n = 4, 1 4 10 16 19 16 10 4 1;
So, I want to know the sum of coefficients depending on "n" and also the sum of the coefficients just above the the middle position. I was able to create a recursive formula in Microsoft Excel, but I have no clue on how to create an array out of the coefficients to give different answers, sucha as the sum below the middle element or after the middle element, such as:
if n = 0; sum above = 0;
if n = 1; sum above = 1;
if n = 2; sum above = 3;
if n = 3; sum above = 10;
if n = 4; sum above = 31;

and so on...

The sum of the coefficients is simply n3.

The function, I believe, should look like this:

    int SumAbove(int n)
    {
        int array[][];
        int j = 0;
        array[0][0] = 0;
        for(int i=1;i<=n;i++;j++)
          {
              ((i==0)||(i==(2*n))) ? array[i][j]=1 : array[i][j] = array[i][j-1] + array[i][j]+array[i][j+1];
          }
        int sum = 0;
        for(int i=(n+1);i<=(2*n);i++)
            {
                sum =+ array[n][i]
            }
        return(sum);
    }

A027907 - OEIS
  • oeis.org
A027907 Irregular triangle of trinomial coefficients T(n,k) (n >= 0, 0 <= k <= 2n), read by rows (n-th row is obtained by expanding (1 + x + x^2)^n). OFFSET 0,6 COMMENTS T(n,k) = number of integer strings s(0),...,s(n) such that s(0)=0, s(n)=k, s(i) = s(i-1) + c, where c is 0, 1 or 2. Columns of...
 

Sum = 3^n.


From here

 
fxsaber:

Sum = 3^n.


From here

Yes, Σ = 3n.


 
fxsaber:

Sum = 3^n.


From here

But I am more interested in n, k coefficient and the sum for k<n.
int n = 9;

int a_array[][];

a_array[0][0] = 1;

for(int i=1;i<=n;i++)
  {
   for(int k=0;k<=(2*i);k++)
     {
      a_array[i][k] =
         ((k-2)>=0)?a_array[i-1][k-2]:0 +
         ((k-1)>=0)?a_array[i-1][k-1]:0 +
         (k<=(2*i))?a_array[i-1][k]:0;
     };
  };
Perhaps I am getting closer. Am I?
 

 
 
Arthur Albano:
An absolutely non-parametric study of anomalies that arise from time to time in market trading. There's no such a thing as period, volume or price levels as inputs.
 

I  saw  another trader trading bimodal - multimodal distributions.But how do  you trade the bimodal - multimodal distributions ?Do you  evaluate  your  trading results on multimodal trinomial distribution criteria? Do you trade  the multimodal trinomial distribution of  price?  etc..

When I google ''multimodal trinomial distribution criteria for  trading'' I can only find few  papers based on option pricing. 

 
nevar:

I  saw  another trader trading bimodal - multimodal distributions.But how do  you trade the bimodal - multimodal distributions ?Do you  evaluate  your  trading results on multimodal trinomial distribution criteria? Do you trade  the multimodal trinomial distribution of  price?  etc..

When I google ''multimodal trinomial distribution criteria for  trading'' I can only find few  papers based on option pricing. 

Take a close look at the following book and tell me if there is a support and resistance based on the volumes. Where will the price land?


 

If you want to do this in MQL the problem is the dynamic 2-dimensional array. As far as I know you can only resize one dimension but not two. Let's assume you know the maximum value of n, say MAX_N, that would make things easier.

What you want is the Trinomial Triangle as shown in #4, especially the values of the center row (1,1,3,7,19,...) and the sum thereof. From all what I've read in the article you have to compute the values recursively.

#define MAX_N 10
int Triangle[MAX_N+1][MAX_N+1];

void TriangleInit() {
   Triangle[0][0] = 1;

   for(int n=1;n<=MAX_N;n++) {
      for(int k=0;k<=n;k++) {
         Triangle[n][k] =
            (k-1>=0 ? Triangle[n-1][k-1] : Triangle[n-1][1]) +
            (n-1>=k ? Triangle[n-1][k] : 0) +
            (n-1>=k+1 ? Triangle[n-1][k+1] : 0);
      }
   }
}

int Trinomial(int n,int k) {
   if(k<0) k=-k;
   return (n>=0 && k<=n ? Triangle[n][k] : 0);
}

The rows of the triangle are counted from 0 upwards that is n>=0, and the middle column is denoted by k=0. That means Trinomial(4,0) is expected to return 19 (row 4, middle column.)

The sum of all values above a center value at row n is built by summing up Trinomial(i,0) for i<n.

Trinomial triangle - Wikipedia
  • en.wikipedia.org
The trinomial triangle is a variation of Pascal's triangle. The difference between the two is that an entry in the trinomial triangle is the sum of the three (rather than the two in Pascal's triangle) entries above it: . Rows are counted starting from 0. The entries of the -th row are indexed starting with from the left, and the middle entry...
 
Arthur Albano:

Take a close look at the following book and tell me if there is a support and resistance based on the volumes. Where will the price land?

An order book means nothing. Virtual SL/TP, Iceberg orders, even fake orders, volume that is not executed could mean anything. Why throw heavy computations against an order book?

2010 Flash Crash - Wikipedia
2010 Flash Crash - Wikipedia
  • en.wikipedia.org
When new regulations put in place following the 2010 Flash Crash[9] proved to be inadequate to protect investors in the August 24, 2015 flash crash—"when the price of many ETFs appeared to come unhinged from their underlying value"[9]—ETFs were put under greater scrutiny by regulators and investors.[9] The Commodity Futures Trading Commission...
Reason: