% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/disco.R
\name{disco_samples}
\alias{disco_samples}
\title{Per-sample DISCO scores}
\usage{
disco_samples(X, labels, min_points = 5)
}
\arguments{
\item{X}{A numeric matrix (\eqn{n \times p}) or \code{data.frame}.}

\item{labels}{An integer vector of length \eqn{n} containing cluster labels.
Use \code{-1} to denote noise/outlier points.}

\item{min_points}{A positive integer for the core-distance neighbourhood
size.  Default is \code{5}.}
}
\value{
A numeric vector of length \eqn{n} with per-point DISCO scores.
}
\description{
Computes a pointwise DISCO score for every observation in \code{X}.  The
score lies in \eqn{[-1, 1]}:
\itemize{
  \item Values close to \eqn{1} indicate a well-placed point (either
    tightly within its cluster or a noise point far from all clusters).
  \item Values close to \eqn{0} indicate borderline placement.
  \item Values close to \eqn{-1} indicate a misplaced point (or a noise
    point that should belong to a cluster).
}

Four cases are handled:
\enumerate{
  \item \strong{All noise} — every point labelled \code{-1}: all scores
    are \code{-1}.
  \item \strong{Single cluster with no noise} — all scores are \code{0}.
  \item \strong{One real cluster + noise} — cluster points are scored via
    \code{\link{p_cluster}}; noise points are scored via
    \code{\link{p_noise}}.
  \item \strong{Two or more clusters (optional noise)} — non-noise points
    use \code{\link{p_cluster}} on the non-noise sub-matrix; noise points
    use \code{\link{p_noise}}.
}
}
\examples{
set.seed(42)
X <- matrix(rnorm(100), ncol = 2)
labels <- rep(c(0L, 1L), each = 25)
s <- disco_samples(X, labels)
hist(s, main = "Per-sample DISCO scores")
}
\seealso{
\code{\link{disco_score}}, \code{\link{p_cluster}},
  \code{\link{p_noise}}
}
