Skip to content

Commit

Permalink
Adding a and b as parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalhorton committed Jun 20, 2017
1 parent 3f7f5d2 commit 951f7f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
13 changes: 9 additions & 4 deletions R/performanceScore.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ crps <- function(x, x0, a=0.44, b=0.12, w=NA) {
#'
#' @param A Results of AtmoSwing as parsed by atmoswing::parseAllNcOutputs.
#' @param nb.analogs Number of analogs to consider (all of them if ignored or 0)
#' @param a,b Constants that have a law-dependent optimum from which the samples
#' are derived.
#'
#' @return Vector of the CRPS value for every day of the target period.
#'
Expand All @@ -92,7 +94,7 @@ crps <- function(x, x0, a=0.44, b=0.12, w=NA) {
#'
#' @export
#'
crpsVector <- function(A, nb.analogs = 0) {
crpsVector <- function(A, nb.analogs = 0, a=0.44, b=0.12) {

# Check provided number of analogues
if (nb.analogs == 0) {
Expand All @@ -105,16 +107,17 @@ crpsVector <- function(A, nb.analogs = 0) {
}

# Calculation on a single row
crpsPerRow <- function(analog.values, target.value, nb.analogs) {
return (atmoswing::crps(analog.values[1:nb.analogs], target.value))
crpsPerRow <- function(analog.values, target.value, nb.analogs, a, b) {
return (atmoswing::crps(analog.values[1:nb.analogs], target.value, a=a, b=b))
}

# Apply on the whole matrix
crps.vect <- t(mapply(
crpsPerRow,
split(A$analog.values.norm, row(A$analog.values.norm)),
A$target.values.norm,
nb.analogs
nb.analogs,
a, b
))

return(crps.vect)
Expand All @@ -128,6 +131,8 @@ crpsVector <- function(A, nb.analogs = 0) {
#' @param A Results of AtmoSwing as parsed by atmoswing::parseAllNcOutputs.
#' @param scale Importance given to the weights (0 to 1)
#' @param nb.analogs Number of analogs to consider (all of them if ignored or 0)
#' @param a,b Constants that have a law-dependent optimum from which the samples
#' are derived.
#'
#' @return Vector of the CRPS value for every day of the target period.
#'
Expand Down
5 changes: 4 additions & 1 deletion man/crpsVector.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/crpsVectorWeightedByCriteria.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 951f7f7

Please sign in to comment.