

   nneeaarreesstt nneeiigghhbboouurr ddiissttaanncceess ffrroomm ddaattaa iinn oonnee oorr ttwwoo ddiimmeenn--
   ssiioonnss

        nnbr(x, k)

   AArrgguummeennttss::

          x: the vector, or two-column matrix, of data.

          k: the required order of nearest neighbour.

   DDeessccrriippttiioonn::

        This function calculates the `k' nearest neighbour dis-
        tance from each value in `x' to the remainder of the
        data.  In two dimensions, Euclidean distance is used
        after standardising the data to have unit variance in
        each component.

   DDeettaaiillss::

        see Section 1.7.1 of the reference below.

   VVaalluuee::

        the vector of nearest neighbour distances.

   SSiiddee EEffffeeccttss::

        none.

   RReeffeerreenncceess::

        Bowman, A.W. and Azzalini, A. (1997). Applied Smoothing
        Techniques for Data Analysis: the Kernel Approach with
        S-Plus Illustrations.  Oxford University Press, Oxford.

   SSeeee AAllssoo::

        none.

   EExxaammpplleess::

        x  <- rnorm(50)
        hw <- nnbr(x, 10)
        hw <- hw/exp(mean(log(hw)))
        sm.density(x, h.weights=hw)

