private void compute() {
    if (computed) {
      return;
    }
    float sum = 0;
    int n = 0;
    while (true) {
      float val;
      try {
        val = floatVal(n);
      } catch (ArrayIndexOutOfBoundsException e) {
        break;
      }
      sum += val;
      minVal = Float.isNaN(minVal) ? val : Math.min(minVal, val);
      maxVal = Float.isNaN(maxVal) ? val : Math.max(maxVal, val);
      ++n;
    }

    avgVal = n == 0 ? Float.NaN : sum / n;
    computed = true;
  }