Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

New Post: Function of vectors

$
0
0
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.

I tried

let f2 (p:Vector<float>, q:Vector<float>) =

but didn't get anywhere.

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>