+ same_pollution = (distances <= dist_thresh)
+ nb_neighbs = sum(same_pollution)
+ if (nb_neighbs >= min_neighbs) #will eventually happen
+ break
+ dist_thresh = dist_thresh + 3
+ }
+ fdays = fdays[same_pollution]
+ max_neighbs = 10
+ if (nb_neighbs > max_neighbs)
+ {
+ # Keep only max_neighbs closest neighbors
+ fdays = fdays[ sort(distances[same_pollution],index.return=TRUE)$ix[1:max_neighbs] ]
+ }
+ if (length(fdays) == 1) #the other extreme...
+ {
+ if (final_call)
+ {
+ private$.params$weights <- 1
+ private$.params$indices <- fdays
+ private$.params$window <- 1
+ }
+ return ( data$getSerie(fdays[1])[1:horizon] ) #what else?!