I want to calculate the ratio COV(X,Y) / VAR(X) of two vectors. Each function returns a Tensor
of singleton type. There is no Nx.div
and I didn’t find how to cast a (1,1) tensor into a float.
Any clue?
There are Nx.divide and Nx.quotient. You also probably don’t need to explicitly cast to float, although you can with Nx.as_type.
Finally, Scholar has a covariance function (scholar/covariance.ex at main · elixir-nx/scholar · GitHub) which might be useful. You have to install from github, though.
Nx.variance is there already, though.
2 Likes