Skip to content

Commit 398f06a

Browse files
committed
improve docs of k arg of nn2
* closes #36
1 parent d45c95d commit 398f06a

3 files changed

Lines changed: 57 additions & 53 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ BugReports: https://github.com/jefferislab/RANN/issues
3030
Suggests:
3131
testthat
3232
Encoding: UTF-8
33-
RoxygenNote: 7.3.2
33+
RoxygenNote: 7.3.3

R/nn.R

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,54 @@
66

77
#'Nearest Neighbour Search
88
#'
9-
#'Uses a kd-tree to find the p number of near neighbours for each point in an
10-
#'input/output dataset. The advantage of the kd-tree is that it runs in O(M log
9+
#'Uses a kd-tree to find the p number of near neighbours for each point in an
10+
#'input/output dataset. The advantage of the kd-tree is that it runs in O(M log
1111
#'M) time.
1212
#'
13-
#'The \code{RANN} package utilizes the Approximate Near Neighbor (ANN) C++
14-
#'library, which can give the exact near neighbours or (as the name suggests)
15-
#'approximate near neighbours to within a specified error bound. For more
16-
#'information on the ANN library please visit
13+
#'The \code{RANN} package utilizes the Approximate Near Neighbor (ANN) C++
14+
#'library, which can give the exact near neighbours or (as the name suggests)
15+
#'approximate near neighbours to within a specified error bound. For more
16+
#'information on the ANN library please visit
1717
#'\url{https://www.cs.umd.edu/~mount/ANN/}.
1818
#'
19-
#'Search types: \code{priority} visits cells in increasing order of distance
20-
#'from the query point, and hence, should converge more rapidly on the true
21-
#'nearest neighbour, but standard is usually faster for exact searches.
22-
#'\code{radius} only searches for neighbours within a specified radius of the
23-
#'point. If there are no neighbours then nn.idx will contain 0 and nn.dists
19+
#'Search types: \code{priority} visits cells in increasing order of distance
20+
#'from the query point, and hence, should converge more rapidly on the true
21+
#'nearest neighbour, but standard is usually faster for exact searches.
22+
#'\code{radius} only searches for neighbours within a specified radius of the
23+
#'point. If there are no neighbours then nn.idx will contain 0 and nn.dists
2424
#'will contain 1.340781e+154 for that point.
2525
#'
26-
#'@param data An \bold{M} x \bold{d} data.frame or matrix, where each of the
26+
#'@param data An \bold{M} x \bold{d} data.frame or matrix, where each of the
2727
#' \bold{M} rows is a point or a (column) vector (where \bold{d=1}).
28-
#'@param query A set of \bold{N} x \bold{d} points that will be queried against
29-
#' \code{data}. \bold{d}, the number of columns, must be the same as
28+
#'@param query A set of \bold{N} x \bold{d} points that will be queried against
29+
#' \code{data}. \bold{d}, the number of columns, must be the same as
3030
#' \code{data}. If missing, defaults to \code{data}.
31-
#'@param k The maximum number of nearest neighbours to compute. The default
32-
#' value is set to the smaller of the number of columnns in data
31+
#'@param k The maximum number of nearest neighbours to compute. The default
32+
#' value is set to the smaller of the number of data points (rows) and 10. Note
33+
#' that when data and query are the same then the nearest neighbour will be the
34+
#' query point itself.
3335
#'@param treetype Character vector specifying the standard \code{'kd'} tree or a
34-
#' \code{'bd'} (box-decomposition, AMNSW98) tree which may perform better for
36+
#' \code{'bd'} (box-decomposition, AMNSW98) tree which may perform better for
3537
#' larger point sets
3638
#'@param searchtype See details
3739
#'@param radius Radius of search for searchtype='radius'
3840
#'@param eps Error bound: default of 0.0 implies exact nearest neighbour search
3941
#'@return A \code{list} of length 2 with elements:
40-
#'
42+
#'
4143
#' \item{nn.idx}{A \bold{N} x \bold{k} integer \code{matrix} returning the near
4244
#' neighbour indices.}
43-
#'
44-
#' \item{nn.dists}{A \bold{N} x \bold{k} \code{matrix} returning the near
45+
#'
46+
#' \item{nn.dists}{A \bold{N} x \bold{k} \code{matrix} returning the near
4547
#' neighbour Euclidean distances.}
46-
#'@author Gregory Jefferis based on earlier code by Samuel E. Kemp (knnFinder
48+
#'@author Gregory Jefferis based on earlier code by Samuel E. Kemp (knnFinder
4749
#' package)
48-
#'@references Bentley J. L. (1975), Multidimensional binary search trees used
50+
#'@references Bentley J. L. (1975), Multidimensional binary search trees used
4951
#' for associative search. Communication ACM, 18:309-517.
50-
#'
51-
#' Arya S. and Mount D. M. (1993), Approximate nearest neighbor searching,
52+
#'
53+
#' Arya S. and Mount D. M. (1993), Approximate nearest neighbor searching,
5254
#' Proc. 4th Ann. ACM-SIAM Symposium on Discrete Algorithms (SODA'93), 271-280.
53-
#'
54-
#' Arya S., Mount D. M., Netanyahu N. S., Silverman R. and Wu A. Y (1998), An
55+
#'
56+
#' Arya S., Mount D. M., Netanyahu N. S., Silverman R. and Wu A. Y (1998), An
5557
#' optimal algorithm for approximate nearest neighbor searching, Journal of the
5658
#' ACM, 45, 891-923.
5759
#'@keywords nonparametric

man/nn2.Rd

Lines changed: 28 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)