code: @Override
      public void learn(double[] x, double y) {
          if (x.length != p) {
              throw new IllegalArgumentException(String.format("Invalid input vector size: %d, expected: %d", x.length, p));
          }
  
          System.arraycopy(x, 0, x1, 0, p);
          double v = 1 + V.xax(x1);
          // If 1/v is NaN, then the update to V will no longer be invertible.
          // See https://en.wikipedia.org/wiki/Sherman%E2%80%93Morrison_formula#Statement
          if (Double.isNaN(1/v)){
              throw new IllegalStateException("The updated V matrix is no longer invertible.");
          }
  
          V.ax(x1, Vx);
          for (int j = 0; j <= p; j++) {
              for (int i = 0; i <= p; i++) {
                  double tmp = V.get(i, j) - ((Vx[i] * Vx[j])/v);
                  V.set(i, j, tmp/lambda);
              }
          }
  
          // V has been updated. Compute Vx again.
          V.ax(x1, Vx);
          
          double err = y - predict(x);
          for (int i = 0; i <= p; i++){
              w[i] += Vx[i] * err;
          }
      }
docs: Learn a new instance with online regression.
  @param x the training instance.
  @param y the target value.