[mlpack-git] [mlpack/mlpack] Vantage point tree (#708)

Ryan Curtin notifications at github.com
Thu Jul 21 19:34:53 EDT 2016


> +
> +    // Get no more than max(maxNumSamples, count) random samples
> +    GetDistinctSamples(samples, maxNumSamples, begin, count);
> +
> +    // Calculate the second moment of the distance to the vantage point candidate
> +    // using these random samples
> +    const ElemType spread = GetSecondMoment(bound, data, samples,
> +        vantagePointCandidates[i]);
> +
> +    if (spread > bestSpread)
> +    {
> +      bestSpread = spread;
> +      vantagePoint = vantagePointCandidates[i];
> +      //  Calculate the median value of the distance from the vantage point candidate
> +      //  to these samples
> +      GetMedian(bound, data, samples, vantagePoint, mu);

This call to `GetMedian()` will duplicate all the distance calculations that are done in `GetSecondMoment()`.  To be honest, since `GetSecondMoment()` and `GetMedian()` are only called once, I would just inline them into this function, which will allow you to more easily avoid the duplicate calculations.  Note also that if you already have an Armadillo object with the distances of each point to the vantage point, you can just call `arma::sum(distances % distances)` to get the sum of squared distances.

---
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/708/files/300882ac96e7a663e3e303ca0c45c14c6fafe1a6#r71806403
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160721/d83444b3/attachment.html>


More information about the mlpack-git mailing list