[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re[2]: calling on all maths gurus .....Algorythm / formula needed



PureBytes Links

Trading Reference Links

Frank,

>>>i have these 5 datastreams
>>>data2 , data3 , data4 , data5 , data6

>bingo

Well, OK, all he needs to do is change the starting value of the
loop to 2 instead of 1.  And N=6, the index of the last data stream.


>>>and i want every possible combination of [up to 3 of] these
>
>AM> That's simple IF you want only every permutation of three of them.
>AM> You just have a triple nested loop like so:
>
>AM> ---------------------------------------------------------------------
>AM> vars: N(0), d1(0), d2(0), d3(0);
>AM> {N = number of data streams (data1 ... dataN)}
>
>AM> for d1 = 1 to N-2 begin
>AM>    for d2 = d1+1 to N-1 begin
>AM>       for d3 = d2+1 to N begin
>
>AM>          {your code goes here, and you reference the three
>AM>           data streams as data(d1), data(d2) and data(d3),
>AM>           instead of explicityly referencing data3, data7, etc.}
>
>AM>       end;
>AM>    end;
>AM> end;
>AM> ---------------------------------------------------------------------
>
>AM> However, if you want to get single and pair combos as well as triple
>AM> combos, you need to change the loop bounds to allow for duplicates,
>AM> and then make comparisons to check when 2 or more are duplicated,
>AM> and have separate code sections to handle singles, pairs of values,
>AM> and three values.  Like this:
>
>AM> ---------------------------------------------------------------------
>
>AM> for d1 = 1 to N begin
>AM>    for d2 = d1 to N begin
>AM>       for d3 = d2 to N begin
>
>AM>          if d1=d2 AND d2=d3 then begin
>AM>             {code for single value goes here, just use data(d1)}
>AM>          end
>
>AM>          else if d1=d2 OR d2=d3
>AM>             {code for pair combos goes here; use data(d1) and data(d3)
>AM>              as your data streams}
>AM>          end
>
>AM>          else
>AM>             {code for triple combos goes here; use
>AM>              data(d1), data(d2) and data(d3)}
>AM>          end;
>
>AM>       end;
>AM>    end;
>AM> end;
>AM> ---------------------------------------------------------------------

-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com