Machine learning in trading: theory, models, practice and algo-trading - page 1800

 
Aleksey Vyazmikin:

Please help in solving a combinatorics problem!

There are N different unrepeatable elements, you need to take from them X element(s) at a time, with the input value being the number of the combination of all possible elements.

Is there a formula or function for this?

The input function should get the array with the elements, the number of elements in the combination and the number of the combination, and the output should be an array with the indexes of the elements.

Help, please!

Maybe it's easier to look for X random ones out of N?
If you work with number of combination, then you have to build that combination internally from the number.

And there can be a huge number of combination numbers. For example to pick 10 out of 100 would be millions or billions (something to some degree). How will you decide which combination to take? 1,2, 158451, or 5454554 ?

Random unique is easier to find, just randomly select 1 from N., then the second, etc. up to X.
When selecting, if the item is already selected, you skip the duplicate and repeat the selection. I.e. there will be more attempts than X. For example, if you take 90 out of 100, there will be a lot of duplicate attempts.

For speed, you can drop the selected element from the N array and select from the N-1 remaining elements. (Swap the selected element with the last one and shorten the array by 1.) This way you will find X random elements in exactly X attempts. If N > 3000 elements, it is better not to use built-in random generator, but a more complicated one. Here is a comparison of randoms.

Как MathRand() генерирует значения?
Как MathRand() генерирует значения?
  • 2010.08.06
  • www.mql5.com
Общее обсуждение: Как MathRand() генерирует значения?
 
Aleksey Nikolayev:

That might work.

Or you can take a look at "Combinations" paragraph in Okulov's "Programming in Algorithms" textbook

Is there a formula for getting the combination from the index? Can you write it, please?

 
Valeriy Yastremskiy:

Optimizable parameters and growth zones of the balance drop. The idea is interesting not to optimize, but to pull out the significant characteristics for the growth zones of the balance drop, but the science says that it is difficult or impossible through any characteristics of BP in the presence of SB. And it is difficult to find mathematical models describing the series with sufficient accuracy, and it is not clear what size BP is needed.

Symmetrical conditions seem more correct to me. The series can also flip. ))))

Science can say a lot of things, but we must try and check the potential, maybe it is not ideal, and the non-ideal will be sufficient to improve performance in general.

 
elibrarius:

Maybe it is easier to look for X random from N?
If you work with the number of combinations, you have to build that combination internally from the number.

And the combination numbers can be a huge number. For example to choose 10 out of 100. There will be millions or billions (something to some extent). How will you decide which combination to take? 1,2, 158451, or 5454554 ?

Random unique is easier to find, you just randomly select 1 from N., then the second, and so on to X.
When selecting, if the item is already selected, you skip the duplicate and repeat the selection. I.e. there will be more attempts than X. For example, if you take 90 out of 100, there will be a lot of duplicate attempts.

For speed, you can drop the selected element from the N array and select from the N-1 remaining elements. (Swap the selected element with the last one and shorten the array by 1.) This way you will find X random elements in exactly X attempts. If N > 3000 elements, it is better not to use built-in random generator, but a more complicated one. Comparison of randoms here.

The goal is precisely to overshoot. The 250,000 leaves yielded 15,000 unique splits. A complete enumeration of leaves with 3 splits would take about 250 days, as I estimated, per target value. I think the splits should be grouped together by selecting the initial splits and looking for splits that activate in their area, and then trying each group separately. This approach will significantly reduce the number of combinations.

 
Aleksey Vyazmikin:

Is there a formula for getting the combination from the index? Can you write it, please?

It's not a formula, it's an algorithm. Look at Okulov, it's not much, and it's not complicated.

 
Aleksey Nikolayev:

It's not a formula, it's an algorithm. Look at Okulov, it's not much, and it's not complicated.

I just downloaded and looked - thank you!

If you assessed it as "easy", you must have understood it, but I don't - I don't understand the programming language, the text description is unclear, can I ask you questions about the material?

 
Aleksey Vyazmikin:

I just downloaded and looked - thank you!

If assessed as "uncomplicated", then apparently you figured it out, but I'm not - I do not understand the programming language there, in the text description is unclear, can I ask you questions on the material?

If the measure, then ask. The idea there is simple - build an array (two-dimensional) of all combinations and then take a row (or column) by number. You have two choices - either store the array or recalculate it every time (which saves either memory or time).

Here's an example in R:

#  i - номер, n - элементов исходно, k - сколько выбираем из n
i2c <- function (i,n,k) {m <- combn(n,k); m[,i]}

> i2c(3,10,5)
[1] 1 2 3 4 7
 
Aleksey Nikolayev:

If to the extent, then set it. The idea there is simple - build an array (two-dimensional) of all combinations and then take a row (or column) by number. You have two choices - either store the array or recalculate it every time (which saves either memory or time).

Here is an example in R:

The array is built with loops, and this is a waste of time, not very suitable. The variant of finding a value by calculation, without a complete table beforehand is interesting.

 
Aleksey Vyazmikin:

The array is built through cycles, and this is a waste of time, not very suitable. The option of finding a value by calculation, without a complete table beforehand, is interesting.

I'm not sure if there is such a formula.

 
Aleksey Nikolayev:

I'm not sure there is such a formula.

There must be some algorithm, but it turns out that for 15000 elements of 3 combinations you need to keep the array in memory for 4 terabytes! And even more, I calculated, if you spend 8 bits per element.

Reason: