code: public float linear(float[] x, int m) {
      float result = (float) 1.0;
      int M = x.length;
  
      for (int i = 1; i <= M - m; i++) {
        result *= x[i - 1];
      }
  
      if (m != 1) {
        result *= (1 - x[M - m]);
      }
  
      return result;
    }
docs: Calculate a linear shape