/** returns the mean of the samples added to this instance. Only returns meaningful results when at least window_size samples * as specified in the constructor have been added. * @return the mean */ public float getMean () { if (hasEnoughData()) { if (dirty) { float mean = 0; for (int i = 0; i < values.length; i++) mean += values[i]; this.mean = mean / values.length; dirty = false; } return this.mean; } else return 0; }
/** returns the mean of the samples added to this instance. Only returns meaningful results when at least window_size samples * as specified in the constructor have been added. * @return the mean */ public float getMean () { if (hasEnoughData()) { if (dirty) { float mean = 0; for (int i = 0; i < values.length; i++) mean += values[i]; this.mean = mean / values.length; dirty = false; } return this.mean; } else return 0; }
/** @return A new <code>float[]</code> containing all values currently in the window of the stream, in order from oldest to * latest. The length of the array is smaller than the window size if not enough data has been added. */ public float[] getWindowValues () { float[] windowValues = new float[added_values]; if (hasEnoughData()) { for (int i = 0; i < windowValues.length; i++) { windowValues[i] = values[(i + last_value) % values.length]; } } else { System.arraycopy(values, 0, windowValues, 0, added_values); } return windowValues; } }
/** @return A new <code>float[]</code> containing all values currently in the window of the stream, in order from oldest to * latest. The length of the array is smaller than the window size if not enough data has been added. */ public float[] getWindowValues () { float[] windowValues = new float[added_values]; if (hasEnoughData()) { for (int i = 0; i < windowValues.length; i++) { windowValues[i] = values[(i + last_value) % values.length]; } } else { System.arraycopy(values, 0, windowValues, 0, added_values); } return windowValues; } }
/** @return The standard deviation */ public float standardDeviation () { if (!hasEnoughData()) return 0; float mean = getMean(); float sum = 0; for (int i = 0; i < values.length; i++) { sum += (values[i] - mean) * (values[i] - mean); } return (float)Math.sqrt(sum / values.length); }
/** @return The standard deviation */ public float standardDeviation () { if (!hasEnoughData()) return 0; float mean = getMean(); float sum = 0; for (int i = 0; i < values.length; i++) { sum += (values[i] - mean) * (values[i] - mean); } return (float)Math.sqrt(sum / values.length); }
/** Add a value and update all fields. * @param value The value to add */ public void put (float value) { latest = value; total += value; count++; average = total / count; if (mean != null) { mean.addValue(value); this.value = mean.getMean(); } else this.value = latest; if (mean == null || mean.hasEnoughData()) { if (this.value < min) min = this.value; if (this.value > max) max = this.value; } }
/** Add a value and update all fields. * @param value The value to add */ public void put (float value) { latest = value; total += value; count++; average = total / count; if (mean != null) { mean.addValue(value); this.value = mean.getMean(); } else this.value = latest; if (mean == null || mean.hasEnoughData()) { if (this.value < min) min = this.value; if (this.value > max) max = this.value; } }
System.out.println("DecalPerformanceTest2 fps: " + frames + " at spritecount: " + toRender.size()); fps.addValue(frames); if (fps.hasEnoughData()) { float factor = fps.getMean() / (float)TARGET_FPS; int target = (int)(toRender.size() * factor);
/** returns the mean of the samples added to this instance. Only returns meaningful results when at least window_size samples * as specified in the constructor have been added. * @return the mean */ public float getMean () { if (hasEnoughData()) { if (dirty) { float mean = 0; for (int i = 0; i < values.length; i++) mean += values[i]; this.mean = mean / values.length; dirty = false; } return this.mean; } else return 0; }
/** @return A new <code>float[]</code> containing all values currently in the window of the stream, in order from oldest to * latest. The length of the array is smaller than the window size if not enough data has been added. */ public float[] getWindowValues () { float[] windowValues = new float[added_values]; if (hasEnoughData()) { for (int i = 0; i < windowValues.length; i++) { windowValues[i] = values[(i + last_value) % values.length]; } } else { System.arraycopy(values, 0, windowValues, 0, added_values); } return windowValues; } }
/** @return The standard deviation */ public float standardDeviation () { if (!hasEnoughData()) return 0; float mean = getMean(); float sum = 0; for (int i = 0; i < values.length; i++) { sum += (values[i] - mean) * (values[i] - mean); } return (float)Math.sqrt(sum / values.length); }
/** Add a value and update all fields. * @param value The value to add */ public void put (float value) { latest = value; total += value; count++; average = total / count; if (mean != null) { mean.addValue(value); this.value = mean.getMean(); } else this.value = latest; if (mean == null || mean.hasEnoughData()) { if (this.value < min) min = this.value; if (this.value > max) max = this.value; } }