# Homework Help: How to calculate all the possible combinations...?

Tags:
1. Apr 19, 2017

### Richard_Steele

1. The problem statement, all variables and given/known data
Hello, I have to solve a problem to calculate all the possible combinations in a dataset. I have candles and each one has 4 values: open, close, high and low. And I have a high number of candles (hundreds).

I want to know all the possible scenarios that it's possible to obtain with 2 consecutive candles.

For example, I have a candle:

B1 can be below or above C1 (in the picture, there is only 1 candle and 2 different situations):

As you can see, it has 4 variables (Max, min, open and close).

What happens when we have 2 candles and we want to compare them
Once we have 2 consecutive candles, there are different scenarios that we can find. Those possible scenarios are the things I want to calculate. How many combinations is it possible to find between 2 consecutive candles?

In this case:
A1 < A2
B1 > B2
C1 > C2
D1 > D2

But if we want to calculate all the possible combinations:
A1 > A2 or A1 < A2 or A1 = A2
A1 can be higher, lower or equal to B2
etc...

So we have different relations between the components:
A1-A2, A1-B2, A1-C2...
B1-A2, B1-B2, B1-C2...

And the relations between the components...
>, < or =

So I don't know what kind of formulas or mathematic fields I need to calculate all the possible scenarios. I have thought about combinatorics, but maybe I have use also relational algebra.

But to start with, I would appreciate if someone explains here how to solve this problem.

2. Relevant equations

3. The attempt at a solution

2. Apr 19, 2017

### haruspex

I am not at all sure I understand the question. Is this it:
You have an ordered set of N candles.
The candles are vertical.
Each candle has an open end and a closed end.
All candles are the same length (true?).
For any given candle, two parameters describe its state: its vertical position and which way up it is.
For the state of the system, you only care about which way up the candles are and the ranking of their heights.

If the candles are of arbitrary lengths then you care about the ranking of the heights of their two ends independently.

3. Apr 19, 2017

### Richard_Steele

Hello, I have a set of N candles. The candles are vertical and each candle has 4 variables (maximum, minimum, open and close). Each candle can be equal or different lenght (usually they are different length).

For any given candle 4 instead of 2, parameters are used to describe i: max, min, open and close. If I want to represent 1 candle, I need the 4 parameters to describe the candle.

I care to calculate all the posible qualitative (not quantitative, at this moment) combinations are possible to find in the set.

Here you have a real set:

Despite the colors of the body (black or white). Imagine all candles are black for our thread.

So, the problem I am facing is to calculate all the possible combinations (how can a parameter (max, min, high or low)) be in relation to another candle.

4. Apr 19, 2017

### haruspex

Suppose you have N candles. How many candle ends are there? (For now, assume all are at different heights.). Now add one more. How many possibilities are there for how it is added?

5. Apr 19, 2017

### Richard_Steele

I have made the following observations. Check them and say me if I'm right or not.

I have 2 candles, the first has the index #1, and the second has the index #2.

I assume that if I want to calculate all the possible relations that can exist between each component of the first candle, with each of the components of the second candle, they're a total of 16 interactions. (4 * 4)

Of course, now I have 16 relations and it's possible that each relation gives as a result 3 different properties: higher than, lower than or equal. (<, >, =).

So I think there are 324 possible combinations:
34=81
81 * 4 = 324
I have 3 different results (<, >, =).
I have to apply in a block that has 4 different relations (one component of the first candle interacting with each one of the 4 components of the second candle).
I have four blocks (each block is the interaction of each component of the first candle (4 in total, for that reason there are 4 blocks) with the components of the second candle).

Is it right?

6. Apr 19, 2017

### haruspex

But not all those combinations are possible. If x>y and y=z then x>z.
Start with something a bit simpler. Consider a single number to represent each candle, its midpoint say. So there are just N numbers. And for now, ignore the fact that some might be equal. How many possibilities?

7. Apr 20, 2017

### Richard_Steele

Well, assume that N = 2 , so I have 2 candles. The first and the second candle.

Of course, I assume that they can be > or < (not equal).

So the solution could be: 16? I don't get the idea.

8. Apr 20, 2017

### haruspex

That's making it a bit too simple. Keep it at N. With just one number for each and no equality, this is quite easy, but instructive.
Eh? Just two numbers, one for each candle: x1, x2. One greater than the other. How many possibilities?

9. Apr 21, 2017

### Richard_Steele

Sorry, maybe 2?
X1 > X2
or
X1 < X2

Now better?

10. Apr 21, 2017

### haruspex

11. Apr 22, 2017

### Richard_Steele

I would say that if we have 2 candles and there are 2 possible solutions, then if we have N candles, we will have N possible solutions. Right?

For example, if we have 4 candles, we will have 4 possible solutions?

12. Apr 22, 2017

### haruspex

That's a wild guess. And wrong. You have N numbers to put in some order... Doesn't anything spring to mind?
If not, try N=3 and see if you can write down all the possble orders.

13. Apr 27, 2017

### Richard_Steele

Well, if we have 3 numbers... (call them 1, 2 and 3)

We have the following combinations:
123
132
213
231
312
321

Correct?

14. Apr 27, 2017

### haruspex

Yes. Are you not familiar with the formula for the number of ways to order n objects?

15. May 1, 2017

### Richard_Steele

EDIT: you're asking me about the formula to order n objets. I'm not familiar with it.

I would say you that it's possible to get the result (6 possible combinations) using the permutation formula:

Right?

16. May 1, 2017

### haruspex

Yes. I find it astonishing that you would be expected to answer a question such as in this thread without being familiar with such a basic formula.

Suppose you have n objects to put in order. How many choices for the object to go in the first position? Having made that choice, how many objects do you have left to choose from for the second position? Etc.

17. May 14, 2017

### Richard_Steele

How many choices for the object to go in the first position?
2 choices?
123
132
213
231
312
321

Having made that choice, how many objects do you have left to choose from for the second position?
2 also?

18. May 14, 2017

### haruspex

Your list clearly shows three choices for the first position, 1, 2 or 3. The two you highlighted are the same choice.