Reputation: 159
I have the functions:
lsfit:{(enlist y) lsq x xexp/: til 1+z};
interp:{[xn;x;y]sum (1;xn)*flip lsfit[x;y;1]};
and the table
table:([] amount:500 730 1250;xRng:(0 1;0 1;1 2);yRng:(5 7f; 5 7f; 7 10f));table
amount xRng yRng
500 0 1 5 7f
730 0 1 5 7f
1250 1 2 7 10f
How can I apply interp
to return a column "result" and append it to the table like below?
amount xRng yRng result
500 0 1 5 7f 6
730 0 1 5 7f 6.46
1250 1 2 7 10f 7.75
I was trying something like
interp[first table[`amount]%1000;first table[`xRng];first table[`yRng]]
which works fine for the first row, but not sure how to extent it for the whole table.
Upvotes: 0
Views: 1278
Reputation: 56
You can use the following to apply your function to all the rows:
update result:interp'[amount%1000;xRng;yRng] from table
Upvotes: 4