Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: feanor0I've got a
variable number of input columns called 'Asset0', 'Asset1', ..., 'Asset[NumAssets]' where NumAssets > 0
My data looks a bit like this for NumAssets = 3, say.
Asset0, Asset1, Asset2, Asset3, Term1, Term2
0.1, 0.3, 0.4, 0.5, 0.9, 0.1
0.2, 0.4, 0.5, 0.6, 0.8, 0.2
I want to do the following computation for each of n = 1, 2, ...
value1 = Term1 * Asset0 + Term2 * Asset1
value2 = Term1 * Asset0 + Term2 * Asset2
...
value[NumAssets] = Term1 * Asset0 + Term2 * Asset[NumAssets]
and emit each value as new column called Value1, Value2, ...
(Note that Asset0 always participates in the computation.)
How could I do this? If this is not possible, I don't mind overwriting the Asset1, Asset2, ... columns with the newly computed corresponding Value1, Value2, ...
I tried the following code in a Filter node, but I'm getting errors:
output 1 {
emit wildcard "Asset*"
}
i = 1
while i <= NumAssets {
fieldName = strcat("Asset", i)
value = Asset0 * Term1 + field(fieldName) * Term2
do output 1 {
emit value as strcat("Value", i)
}
i = i + 1
}
Please advise.