- (first:last)[ sapply(first:last, function(i)
- !any( is.na(data$getCenteredSerie(i)) | is.na(data$getCenteredSerie(i+1)) )
- ) ]
-}
-
-#' getConstrainedNeighbs
-#'
-#' Get indices of neighbors of similar pollution level (among same season + day type).
-#'
-#' @param today Index of current day
-#' @param data Object of class Data
-#' @param fdays Current set of "first days" (no-NA pairs)
-#' @param min_neighbs Minimum number of points in a neighborhood
-#' @param max_neighbs Maximum number of points in a neighborhood
-#'
-.getConstrainedNeighbs = function(today, data, fdays, min_neighbs=10, max_neighbs=12)
-{
- levelToday = data$getLevel(today)
- distances = sapply(fdays, function(i) abs(data$getLevel(i)-levelToday))
- #TODO: 2, +3 : magic numbers
- dist_thresh = 2
- min_neighbs = min(min_neighbs,length(fdays))
+ levelToday = data$getLevelHat(today)
+ levelYersteday = data$getLevel(today-1)
+ distances = sapply(tdays, function(i) {
+ sqrt((data$getLevel(i-1)-levelYersteday)^2 + (data$getLevel(i)-levelToday)^2)
+ })
+ #TODO: 1, +1, +3 : magic numbers
+ dist_thresh = 1
+ min_neighbs = min(min_neighbs,length(tdays))