% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/normalize.R
\name{normalize}
\alias{normalize}
\title{Normalize a co-occurrence matrix}
\usage{
normalize(A, method = "none")
}
\arguments{
\item{A}{A square symmetric matrix (dense or sparse) representing
co-occurrence counts.}

\item{method}{Character. Normalization method:
\describe{
\item{\code{"none"}}{No normalization. Returns raw co-occurrence counts.}
\item{\code{"association"}}{Association strength (probabilistic affinity
index). \eqn{s_{ij} = c_{ij} / (w_i \cdot w_j)}.
Often recommended as the best normalization for co-occurrence data.}
\item{\code{"cosine"}}{Salton's cosine.
\eqn{s_{ij} = c_{ij} / \sqrt{w_i \cdot w_j}}.}
\item{\code{"jaccard"}}{Jaccard index.
\eqn{s_{ij} = c_{ij} / (w_i + w_j - c_{ij})}.}
\item{\code{"inclusion"}}{Inclusion index (Simpson coefficient).
\eqn{s_{ij} = c_{ij} / \min(w_i, w_j)}.}
\item{\code{"equivalence"}}{Equivalence index (Salton's cosine squared).
\eqn{s_{ij} = c_{ij}^2 / (w_i \cdot w_j)}.}
}}
}
\value{
A normalized sparse matrix of the same dimensions.
}
\description{
Applies a similarity normalization to a square co-occurrence matrix.
The diagonal of the input matrix is used as the total occurrence count
for each item. Operates entirely in sparse representation.
}
\examples{
# Create a small co-occurrence matrix
A <- matrix(c(10, 3, 1, 3, 8, 2, 1, 2, 5), nrow = 3,
            dimnames = list(c("a", "b", "c"), c("a", "b", "c")))
normalize(A, "association")
normalize(A, "cosine")
normalize(A, "jaccard")
}
