MathMarEcol / pdyer_aus_bio

GNU General Public License v3.0
0 stars 0 forks source link

Add Bhattacharyya distance instead of Hotelling T^2 #2

Closed PhDyellow closed 2 years ago

PhDyellow commented 3 years ago

fpc package and bio3d packages have existing implementations.

fpc requires us to precalculate mean and covariance matrices, which is probably a good idea for speed.

I havn't looked at bio3d yet.

PhDyellow commented 2 years ago

I ended up hand-rolling a Bhattacharyya distance function that assumed Normal distributions. I don't think I was able to calculate the results much faster. The bottleneck for calculating the Bhattacharyya distance for normal distributions is inverting the joint distributions, and the base R chol2inv(chol(joint_cov)) ended up being the fastest way to invert the joint matrix. I was able to test some options for failing early but they didn't help in most cases.