\name{BrierScore}
\alias{BrierScore}
\alias{.BrierScore}
\title{
Compute Brier Score And Its Decomposition And Brier Skill Score
}
\description{
Computes the Brier score (BS) and the components of its standard decomposition as well with the two within-bin components described in Stephenson et al., (2008). It also returns the bias-corrected decomposition of the BS (Ferro and Fricker, 2012). BSS having the climatology as the reference forecast.


.BrierScore provides the same functionality, but taking a matrix of ensemble members (exp) as input.
}
\usage{
BrierScore(obs, pred, thresholds = seq(0, 1, 0.1))

.BrierScore(exp, obs, thresholds = seq(0, 1, 0.1))
}
\arguments{
  \item{obs}{
Vector of binary observations (1 or 0)
  }
  \item{pred}{
Vector of probablistic predictions with values in the range [0,1]
  }
  \item{thresholds}{
Values used to bin the forecasts.  By default the bins are {[0,0.1), [0.1, 0.2), ... [0.9, 1]}
  }
  \item{exp}{
Matrix of predictions with values in the range [0,1] for the .BrierScore function
  }
}
\value{
$rel:                 standard reliability\cr
$res:                 standard resolution\cr
$unc:                 standard uncertainty\cr
$bs:                  Brier score\cr
$bs_check_res:        rel-res+unc\cr
$bss_res:             res-rel/unc\cr
$gres:                generalized resolution\cr
$bs_check_gres:       rel-gres+unc\cr
$bss_gres:            gres-rel/unc\cr
$rel_bias_corrected:  bias-corrected rel\cr
$gres_bias_corrected: bias-corrected gres\cr
$unc_bias_corrected:  bias-corrected unc\cr
$bss_bias_corrected:  gres_bias_corrected-rel_bias_corrected/unc_bias_corrected\cr
$nk:                  number of forecast in each bin\cr
$fkbar:               average probability of each bin\cr
$okbar:               relative frequency that the observed event occurred\cr
$bins:                bins used\cr
$pred:                values with which the forecasts are verified\cr
$obs:                 probability forecasts of the event\cr
}
\examples{
a <- runif(10)
b <- round(a)
x <- BrierScore(b, a)
x$bs - x$bs_check_res
x$bs - x$bs_check_gres
x$rel_bias_corrected - x$gres_bias_corrected + x$unc_bias_corrected
 \dontrun{
  a <- runif(10)
  b <- cbind(round(a),round(a)) # matrix containing 2 identical ensemble members...
  x2 <- BrierScore(a, b)
  }
}
\references{
Wilks (2006) Statistical Methods in the Atmospheric Sciences.\cr
Stephenson et al. (2008). Two extra components in the Brier score decomposition. Weather and Forecasting, 23: 752-757.\cr
Ferro and Fricker (2012). A bias-corrected decomposition of the BS. Quarterly Journal of the Royal Meteorological Society, DOI: 10.1002/qj.1924.\cr
}
\author{
History:\cr
0.1  -  2012-04  (L. Rodrigues, \email{lrodrigues@ic3.cat})  -  Original code\cr
1.0  -  2017-02  (A. Hunter, \email{alasdair.hunter at bsc.es})  -  Adapted to veriApply()
}
\keyword{datagen}
