Help on symmetric integer sequence

86 Views Asked by At

I am programming a LRS binomial tree (Li, Ritchken, and Sankarasubramanian) and need to allocate some memory. Therefore at time step $i$ I need the following sequence:

$i=0: (1)$

$i=1: (1,1)$

$i=2: (1,2,1)$

$i=3: (1,3,3,1)$

$i=4: (1,4,6,4,1)$

$i=5: (1,5,10,10,5,1)$

and so forth.

enter image description here

With the following MATLAB code I get

>> i=4; abs(-i:2:i)

ans =

     4     2     0     2     4

But as you can see, this is obviously not correct. Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

The numbers in the sequence are from Pascal's Triangle.

Given row $i$, there are $i+1$ elements, called $I$ with $I=\left\{0,1,2,\ldots,i\right\}$. The $j^{th}$, $j\in I$, element in row $i$ has the value $\dfrac{i!}{j!(i-j)!}$.

This is also the number of possible ways of choosing $j$ elements from a set of $i$ elements where the order the elements are chosen is not important.