code: public boolean addSample(boolean trial, V obj)
      {
          if(drifting)
              throw new UnhandledDriftException();
          if(!trial)
              fails++;
          time++;
          
          if(time < minSamples)
              return false;
          
          final double p_i = fails/(double)time;
          final double s_i = Math.sqrt(p_i*(1-p_i)/time);
          final double ps = p_i+s_i;
          
          //values are updated when pi +si is lower than pmin +smin
          if(ps < p_min + s_min)
          {
              p_min = p_i;
              s_min = s_i;
          }
          
          if (ps > p_min + warningThreshold * s_min)
          {
              if(!warning)//first entry 
              {
                  warning = true;
                  driftStart = time - 1;
              }
              addToHistory(obj);
              if (ps > p_min + driftThreshold * s_min)
              {
                  warning = false;
                  drifting = true;
              }
              return true;
          }
          else//everything is good
          {
              warning = false;
              driftStart = -1;
              clearHistory();
              return false;
          }
      }
docs: Adds a new boolean trial to the detector, with the goal of detecting when
  the number of successful trials ({@code true}) drifts to a new value.
  This detector begins storing a history of the {@code obj} inputs only
  once it has entered a warning state. <br>
  This detector is specifically meant to detect drops in the success rate,
  and will not cause any warning or drift detections for increases in the
  success rate.
  @param trial the result of the trial
  @param obj the object to associate with the trial
  @return {@code true} if we are in a warning or drift state,
  {@code false } if we are not