code: public double Function2D(double x, double y) {
          double frequency = initFrequency;
          double amplitude = initAmplitude;
          double sum = 0;
  
          // octaves
          for (int i = 0; i < octaves; i++) {
              sum += SmoothedNoise(x * frequency, y * frequency) * amplitude;
  
              frequency *= 2;
              amplitude *= persistence;
          }
          return sum;
      }
docs: 2-D Perlin noise function.
  
  @param x X Value.
  @param y Y Value.
  @return Returns function's value at point xy.