|
6 | 6 |
|
7 | 7 | #'Nearest Neighbour Search |
8 | 8 | #' |
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 |
11 | 11 | #'M) time. |
12 | 12 | #' |
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 |
17 | 17 | #'\url{https://www.cs.umd.edu/~mount/ANN/}. |
18 | 18 | #' |
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 |
24 | 24 | #'will contain 1.340781e+154 for that point. |
25 | 25 | #' |
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 |
27 | 27 | #' \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 |
30 | 30 | #' \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. |
33 | 35 | #'@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 |
35 | 37 | #' larger point sets |
36 | 38 | #'@param searchtype See details |
37 | 39 | #'@param radius Radius of search for searchtype='radius' |
38 | 40 | #'@param eps Error bound: default of 0.0 implies exact nearest neighbour search |
39 | 41 | #'@return A \code{list} of length 2 with elements: |
40 | | -#' |
| 42 | +#' |
41 | 43 | #' \item{nn.idx}{A \bold{N} x \bold{k} integer \code{matrix} returning the near |
42 | 44 | #' 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 |
45 | 47 | #' 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 |
47 | 49 | #' package) |
48 | | -#'@references Bentley J. L. (1975), Multidimensional binary search trees used |
| 50 | +#'@references Bentley J. L. (1975), Multidimensional binary search trees used |
49 | 51 | #' 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, |
52 | 54 | #' 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 |
55 | 57 | #' optimal algorithm for approximate nearest neighbor searching, Journal of the |
56 | 58 | #' ACM, 45, 891-923. |
57 | 59 | #'@keywords nonparametric |
|
0 commit comments