% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build_distance_matrix.R
\name{build_distance_matrix}
\alias{build_distance_matrix}
\title{Build Distance/Entropy Matrix}
\usage{
build_distance_matrix(data_input)
}
\arguments{
\item{data_input}{Either:
\itemize{
\item A numeric matrix (\code{sites × time_steps}) as returned by
\code{\link{calculate_hellinger_matrix}}.
\item A named list with elements \code{Sites} and one of
\code{Hellinger_Distances} or \code{Entropies}, as returned by the
legacy \code{get_hellinger_dist} function.
}}
}
\value{
A numeric matrix with:
\item{Rows}{Sites (1 to \code{max(sites)}, sparse if sites are
non-contiguous).}
\item{Columns}{Time steps (partitions T2, T3, … or entropy periods).}
Row names are character site indices. Column names are preserved from
the input where available.
}
\description{
Converts the output of \code{\link{calculate_hellinger_matrix}}
or the legacy \code{get_hellinger_dist} / entropy list into a numeric
\code{sites × time_steps} matrix suitable for change point detection.
}
\details{
In the current pipeline \code{\link{calculate_hellinger_matrix}} already
returns a \code{sites × time_steps} matrix, so calling this function is
usually unnecessary — transposing that matrix directly gives \code{dat_t}
for \code{\link[ecp]{e.agglo}} or \code{\link[ecp]{ks.cp3o}}:

\preformatted{
  hell_mat = calculate_hellinger_matrix(partitions, sites = seq_len(n_sites))
  dat_t    = t(hell_mat)   # time_steps × sites — ready for ECP
}

This function is retained for \strong{backward compatibility} with code that
was written against the old \code{get_hellinger_dist} list format, and as a
convenience wrapper that also accepts entropy lists.

\strong{Input formats accepted:}
\enumerate{
\item A numeric matrix (e.g. from \code{calculate_hellinger_matrix}) —
returned as-is with site rownames normalised.
\item The legacy named list from \code{get_hellinger_dist} containing
\code{$Sites} and \code{$Hellinger_Distances} (list of vectors).
\item An entropy list containing \code{$Sites} and \code{$Entropies}
(list of numeric vectors), used when no Hellinger distances are present.
}
}
\seealso{
\code{\link{calculate_hellinger_matrix}},
\code{\link{detect_changepoints_ecp}}
}
\keyword{internal}
