R/compareFunctions.R

Defines functions compareFunctions

Documented in compareFunctions

#' Compute the probability that two functions yield the same predictions given an acceptable difference in the prediction
#' 
#' 
#' Compute the probability that the two functions yield the same predictions given an acceptable difference in the prediction.
#' 
#' @param predicted_by_first A numeric vector specifying the values predicted by first function
#' @param predicted_by_second A numeric vector specifying the values predicted by second function
#' @param threshold A numeric vector of lenght one specifying the "acceptable difference in the predicted values" 
#' @export



compareFunctions <- function(predicted_by_first, predicted_by_second, threshold) {
  diff <- abs(predicted_by_first - predicted_by_second)
  boolean <- diff<threshold
  acceptCount <- length(boolean[boolean==TRUE]) # counts the TRUE 
  probability <- acceptCount/length(diff)
  return(probability)
}
msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.