\HeaderA{weighted.median}{Weighted Median}{weighted.median}
\keyword{univar}{weighted.median}
\begin{Description}\relax
Compute a weighted median of a numeric vector.
\end{Description}
\begin{Usage}
\begin{verbatim}
weighted.median(x, w, na.rm = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a numeric vector containing the values whose mean is to be computed.
\item[\code{w}] a vector of weights the same length as \code{x} giving
the weights to use for each element of \code{x}.
\item[\code{na.rm}] a logical value indicating whether \code{NA}
values in \code{x} should be stripped before the computation proceeds.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If \code{w} is missing then all elements of \code{x} are
given the same weight.

Missing values in \code{w} are not handled.

The weighted median is the median of the discrete distribution with
values given by \code{x} and probabilities given by \code{w/sum(w)}.
\end{Details}
\begin{Value}
numeric value giving the weighted median
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{median}{median}}, \code{\LinkA{weighted.mean}{weighted.mean}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## GPA from Siegel 1994
wt <- c(5,  5,  4,  1)/15
x <- c(3.7,3.3,3.5,2.8)
xm <- weighted.median(x,wt)
\end{ExampleCode}
\end{Examples}


