% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores.R
\name{spherical_score}
\alias{spherical_score}
\title{Spherical score for binary and categorical forecasts}
\usage{
spherical_score(p, y)
}
\arguments{
\item{p}{Numeric vector in \verb{[0, 1]} for binary forecasts, or a numeric
matrix whose rows are probability vectors for categorical forecasts.}

\item{y}{For binary vector input, numeric vector in \verb{\{0, 1\}}. For
categorical matrix input, integer vector in \verb{\{1, ..., K\}}, where
\code{K = ncol(p)}.}
}
\value{
Numeric vector of scores in \verb{[0, 1]}. Higher is better.
}
\description{
Computes the positively oriented spherical score. Vector probability input
is treated as binary; matrix probability input is treated as categorical.
}
\details{
For binary forecasts, this computes \deqn{S(p, y) =
\frac{py + (1-p)(1-y)}{\sqrt{p^2 + (1-p)^2}}.}
For categorical forecasts, this computes \deqn{S(\mathbf{p}, y) =
\frac{p_y}{\|\mathbf{p}\|_2},}
where \code{p_y} is the forecast probability assigned to the realised category.

Score differences lie in \verb{[-1, 1]}, so use \code{c = 1} for Theorem 1 and
\code{c = 2} for Theorems 2 and 3.
}
\examples{
p <- c(0.2, 0.7, 0.9)
y <- c(0, 1, 1)
spherical_score(p, y)

}
