\name{BrierScore}
\alias{BrierScore}
\alias{.BrierScore}
\title{
Compute Brier Score And Its Decomposition And Brier Skill Score
}
\description{
Returns the values of the BS and its standard decomposition as well as the addition of the two winthin-bin extra components (Stephenson et al., 2008). It also solves the bias-corrected decomposition of the BS (Ferro and Fricker, 2012). BSS having the climatology as the reference forecast.
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

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

.BrierScore(ens, 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{ens}{
Matrix of predictions with values in the range [0,1] for the .BrierScore function
  }
  \item{thresholds}{
Values used to bin the forecasts.  By default the bins are {[0,0.1), [0.1, 0.2), ... [0.9, 1]}
  }
}
\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
}
\author{
History:\cr
0.1  -  2012-04  (L. Rodrigues, \email{lrodrigues@ic3.cat})  -  Original code\cr
}
\keyword{datagen}
