I come from an R background and would like to translate this little R function
kld = function(p,q) ifelse(p == 0 | q == 0, 0, log(p/q)*p)
into F# using Math.NET vectors.
I got as far as this:
let f1 (p:float, q:float) =
if p = 0.0 || q = 0.0 then 0.0
else log(p / q) * p
But unlike R, this function is not vectorized.
p and q should be vectors, and the result should be a vector, too.
let f2 (p:Vector<float>, q:Vector<float>) =
but didn't get anywhere.