I have a multivariable function, from which I'd like to define a marginalization:
f(a,b,c,d,...,z) ---> g(a,1,c,d,...,z)
Generally, g will have fewer argument than f, possibly none (full evaluation). Is it possible to take the output of a function and transform it into a second function?
This is part of a looped Block[] segment in a larger code, where the number of variables, slot positions, and their values are specified anew on each iteration.
Here is my best failed attempt:
PartialEvaluate[func_, totargs_, args_, targets_] :=
Block[{tmp, g, r},
tmp = Table[Slot[i], {i, 1, totargs}];
Do[tmp[[targets[[slot]]]] = args[[slot]];, {slot, 1, Length[targets]}];
g = Function[func @@ tmp]
Return[g];
];
Thanks
g[a_,c_]:= f[a, 1, c]
? $\endgroup$