[mlpack-git] [mlpack/mlpack] Random projection trees (#726)

Ryan Curtin notifications at github.com
Tue Aug 16 15:01:14 EDT 2016


> +{
> +  ElemType dist = 0;
> +
> +  for (size_t i = 0; i < samples.n_elem; i++)
> +    for (size_t j = i + 1; j < samples.n_elem; j++)
> +      dist += metric::SquaredEuclideanDistance::Evaluate(data.col(samples[i]),
> +          data.col(samples[j]));
> +
> +  dist /= (samples.n_elem * (samples.n_elem - 1) / 2);
> +
> +  return dist;
> +}
> +
> +template<typename BoundType, typename MatType>
> +void RPTreeMeanSplit<BoundType, MatType>::GetRandomDirection(
> +    arma::Col<ElemType>& direction)

Ah actually, the function is already there!  `math::RandVector()`.  Maybe it would be useful to add an overload with a parameter that allows you to select the number of dimensions.  Note that selecting a random vector by uniformly sampling and then normalizing as you've done here actually causes bias, because you want to uniformly sample from the surface of a sphere.  I believe the implementation Nishant wrote many years ago uses the Box-Muller transform:

https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/726/files/ea66e5d17914460289974cc61f0669941edc2524#r74999041
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160816/e491997e/attachment.html>


More information about the mlpack-git mailing list