# ExponentialWeightedAverageStatistic

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic.java+class:androidx.media3.exoplayer.upstream.experimental.ExponentialWeightedAverageStatistic)

*** ** * ** ***


```
@UnstableApi
public class ExponentialWeightedAverageStatistic implements BandwidthStatistic
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthStatistic` that calculates estimates using an exponential weighted average.

## Summary

| ### Constants |
|---|---|
| `static final double` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#DEFAULT_SMOOTHING_FACTOR() = 0.9999` The default smoothing factor. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#ExponentialWeightedAverageStatistic()()` Creates an instance with `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#DEFAULT_SMOOTHING_FACTOR()`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#ExponentialWeightedAverageStatistic(double)(double smoothingFactor)` Creates an instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#addSample(long,long)(long bytes, long durationUs)` Adds a transfer sample to the statistic. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#getBandwidthEstimate()()` Returns the bandwidth estimate in bits per second, or `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#ESTIMATE_NOT_AVAILABLE()` if there is no estimate available yet. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#reset()()` Resets the statistic. |

## Constants

### DEFAULT_SMOOTHING_FACTOR

```
public static final double DEFAULT_SMOOTHING_FACTOR = 0.9999
```

The default smoothing factor.

## Public constructors

### ExponentialWeightedAverageStatistic

```
public ExponentialWeightedAverageStatistic()
```

Creates an instance with `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#DEFAULT_SMOOTHING_FACTOR()`.

### ExponentialWeightedAverageStatistic

```
public ExponentialWeightedAverageStatistic(double smoothingFactor)
```

Creates an instance.

| Parameters |
|---|---|
| `double smoothingFactor` | The exponential smoothing factor. |

## Public methods

### addSample

```
public void addSample(long bytes, long durationUs)
```

Adds a transfer sample to the statistic.

| Parameters |
|---|---|
| `long bytes` | The number of bytes transferred. |
| `long durationUs` | The duration of the transfer, in microseconds. |

### getBandwidthEstimate

```
public long getBandwidthEstimate()
```

Returns the bandwidth estimate in bits per second, or `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#ESTIMATE_NOT_AVAILABLE()` if there is no estimate available yet.

### reset

```
public void reset()
```

Resets the statistic. The statistic should drop all samples and reset to its initial state, similar to right after construction.