Convergence using binary?

https://learninghub.kx.com/forums/topic/convergence-using-binary

Hi,

Hope this will be clear enough; I am trying to pass 2 parameters (x;y) to a function, for convergence:

  • "x" being an initial table, which the convergence function will gradually modify until no change, using...
  • "y", a list, which current value allows defining current conditions within the convergence function.
The first "y" value sets the 1st convergence function applied to table "x". The resulting converged table, together with the second "y" value, then feed the next convergence... etc, up until the last item in the "y" list. Basically, the parameter "y" allows the condition(s), within the function to converge, to change as "y" is iterated and feeding the next loop.

The following pseudo code is what I am looking for:

Step 1

f:{[x;y]

cond based on 1st item of y;

x: , until x is stable;

}/[initial table]/[first in list]

Step 2 & following: using table output from previous convergence, together with next element in list:

f:{[x;y]

cond based on n’th item of y;

x: , until x is stable

}/[output table from previous step]/[next in list]

… obviously with the bizarre “/[table]/[list]” interpreted as over . I think it is possible to achieve this through encapsulation and/or .z.s, but my attempts have failed. Any help would be appreciated.

Thx

JP

Precisely (removing the ), many thanks:-)

Funny, I dug into it this am and came up with {f/[x;1 2]}/[t], but didn’t think (still not super fluent in q) about using the projection in the lambda.

Again, thank you for your time and input.

JP

Is this the behavior you’re looking for?

 

q)t:([] a:100?10;b:100?1.) 
q)f:{[x;it]c1:(-1_(>':) (it+1)>x`a),0b;
           c2: 0.5>abs log ratios next x`b;
           cond: $[1=it; c1; c1&c2];
           delete from x where cond|prev cond} 
q)count {f[;y]/[x]}/[t;1 2] 
56