R/hilbert.projection.R

Defines functions hilbert.projection

Documented in hilbert.projection

#'  Get order along the Hilbert curve
#'
#' @param X matrix of values. Observations are unique by rows.
#' @param Sigma Covariance of the data. If provided, uses a Mahalanobis distance.
#'
#' @return Index of orders
#' @export
#'
#' @examples
#' X <- matrix(rnorm(10*3), 3, 10)
#' idx <- hilbert.projection(X)
#' print(idx)
hilbert.projection <- function(X, Sigma = NULL) {
  X <- as.matrix(t(X))
  if(!is.null(Sigma)) {
    X <- backsolve(chol(Sigma), X, transpose = TRUE)
  }
  idx <- hilbert_proj_(X) + 1 # +1 to adjust C to R indexing
  return(idx)
}

Try the approxOT package in your browser

Any scripts or data that you put into this service are public.

approxOT documentation built on May 29, 2024, 3:12 a.m.