Пример #1
0
void AdaptivePaddedAverage::sample(float new_sample) {
    // Compute new adaptive weighted average based on new sample.
    AdaptiveWeightedAverage::sample(new_sample);

    // Now update the deviation and the padded average.
    float new_avg = average();
    float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg),
                    deviation());
    set_deviation(new_dev);
    set_padded_average(new_avg + padding() * new_dev);
    _last_sample = new_sample;
}
void AdaptivePaddedAverage::sample(double new_sample) {
  // Compute our parent classes sample information
  AdaptiveWeightedAverage::sample(new_sample);

  // Now compute the deviation and the new padded sample
  float new_avg = average();
  float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg),
                                           deviation());
  set_deviation(new_dev);
  set_padded_average(new_avg + padding() * new_dev);
  _last_sample = new_sample;
}
Пример #3
0
void AdaptivePaddedNoZeroDevAverage::sample(float new_sample) {
    // Compute our parent classes sample information
    AdaptiveWeightedAverage::sample(new_sample);

    float new_avg = average();
    if (new_sample != 0) {
        // We only create a new deviation if the sample is non-zero
        float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg),
                        deviation());

        set_deviation(new_dev);
    }
    set_padded_average(new_avg + padding() * deviation());
    _last_sample = new_sample;
}