Number of ways to combine two sets of values

1.1k Views Asked by At

Good day. I have an algorithm which iterates over a set of values

S =[1  -1  0.5  -0.5]

for a set of parameters in vector

P_n = [p1 p2 p3 ... pn]

Such that when these two are combined in iteration the result for a P_2 and S is:

 [p1   p2]
 [p1  -p2]
 [p1  0.5p2]
 [p1  -0.5p2]

 [-p1   p2]
 [-p1  -p2]
 [-p1  0.5p2]
 [-p1  -0.5p2]

 [0.5p1   p2]
 [0.5p1  -p2]
 [0.5p1  0.5p2]
 [0.5p1  -0.5p2]

 [-0.5p1   p2]
 [-0.5p1  -p2]
 [-0.5p1  0.5p2]
 [-0.5p1  -0.5p2] 

How do I describe this result mathematically? The binomial (4 on P_n) almost gives me the correct result but it does not account for double usage of the same element such as:

[1*p1 1*p2]
[-1*p1 -1*p2]
[0.5*p1 0.5*p2]
[-0.5*p1 -0.5*p2]
1

There are 1 best solutions below

0
On BEST ANSWER

The two numbers from S are being chosen with replacement (you can choose the same number twice) giving $4\times 4=16$ possible arrangements of 2 numbers from 4. Your $p_1, p_2$ values are ordered in your list, which can be done in 1 way. This gives 16 possible list elements.

In general, if S has m elements and $P_n$ has n, then the number of such pairs will be ${{m}^{2}}\times {}^{n}{{C}_{2}}$.