% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R
\name{solve_graph_laplacian}
\alias{solve_graph_laplacian}
\title{graph Laplacian approach to finding normalization factors}
\usage{
solve_graph_laplacian(M, niter_irls = 1L)
}
\arguments{
\item{M}{skew-symmetric input matrix, generated with e.g. \code{pairdiff_median()}}

\item{niter_irls}{refine the initial estimate using N additional iterative reweighted least squares loops for robust graph laplacian}
}
\value{
a numeric vector of length \code{ncol(M)} that contains scaling factors for \code{M}
}
\description{
find normalization factors for a given distance matrix computed with e.g. \code{pairdiff_median()}. For increased robustness, this function offers iterative reweighted improvement of the initial estimate.
}
\examples{
# toy example
x = cbind(
  c(1,2,3,4),
  c(2,3,4,9),
  c(1,2,4,5),
  c(1,0,1,0)
)
# compute pairwide median difference between all columns
M = pairscale::pairdiff_median(x)
# solve matrix M to find scaling factors, without and with reweighting
s1 = pairscale::solve_graph_laplacian(M, niter_irls = 0)
s2 = pairscale::solve_graph_laplacian(M, niter_irls = 10)
# rescaled matrices; only the robust variant correctly aligns columns 1 and 2
t(t(x) - s1)
t(t(x) - s2)
}
