Class SlidingPercentile


  • @Deprecated
    public class SlidingPercentile
    extends Object
    Deprecated.
    com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    Calculate any percentile over a sliding window of weighted values. A maximum weight is configured. Once the total weight of the values reaches the maximum weight, the oldest value is reduced in weight until it reaches zero and is removed. This maintains a constant total weight, equal to the maximum allowed, at the steady state.

    This class can be used for bandwidth estimation based on a sliding window of past transfer rate observations. This is an alternative to sliding mean and exponential averaging which suffer from susceptibility to outliers and slow adaptation to step functions.

    See the following Wikipedia articles:

    • Constructor Detail

      • SlidingPercentile

        public SlidingPercentile​(int maxWeight)
        Deprecated.
        Parameters:
        maxWeight - The maximum weight.
    • Method Detail

      • reset

        public void reset()
        Deprecated.
        Resets the sliding percentile.
      • addSample

        public void addSample​(int weight,
                              float value)
        Deprecated.
        Adds a new weighted value.
        Parameters:
        weight - The weight of the new observation.
        value - The value of the new observation.
      • getPercentile

        public float getPercentile​(float percentile)
        Deprecated.
        Computes a percentile by integration.
        Parameters:
        percentile - The desired percentile, expressed as a fraction in the range (0,1].
        Returns:
        The requested percentile value or Float.NaN if no samples have been added.