# ExponentialWeightedAverageStatistic

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic "View this page in Java")

<br />

```
@UnstableApi
class ExponentialWeightedAverageStatistic : BandwidthStatistic
```

<br />

*** ** * ** ***

A[BandwidthStatistic](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/BandwidthStatistic)that calculates estimates using an exponential weighted average.

## Summary

|                                       ### Constants                                       |
|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html) | [DEFAULT_SMOOTHING_FACTOR](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#DEFAULT_SMOOTHING_FACTOR())` = 0.9999` The default smoothing factor. |

|                                                                                                                                                                                                        ### Public constructors                                                                                                                                                                                                         |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ExponentialWeightedAverageStatistic](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#ExponentialWeightedAverageStatistic())`()` Creates an instance with[DEFAULT_SMOOTHING_FACTOR](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#DEFAULT_SMOOTHING_FACTOR()). |
| [ExponentialWeightedAverageStatistic](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#ExponentialWeightedAverageStatistic(double))`(smoothingFactor: `[Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)`)` Creates an instance.                                                                                     |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [addSample](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#addSample(long,long))`(bytes: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, durationUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Adds a transfer sample to the statistic.                                                  |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | [getBandwidthEstimate](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#getBandwidthEstimate())`()` Returns the bandwidth estimate in bits per second, or[ESTIMATE_NOT_AVAILABLE](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#ESTIMATE_NOT_AVAILABLE())if there is no estimate available yet. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [reset](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic#reset())`()` Resets the statistic.                                                                                                                                                                                                                                                                         |

## Constants

### DEFAULT_SMOOTHING_FACTOR

```
const val DEFAULT_SMOOTHING_FACTOR = 0.9999: Double
```

The default smoothing factor.  

## Public constructors

### ExponentialWeightedAverageStatistic

```
ExponentialWeightedAverageStatistic()
```

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

### ExponentialWeightedAverageStatistic

```
ExponentialWeightedAverageStatistic(smoothingFactor: Double)
```

Creates an instance.  

|                                              Parameters                                              |
|------------------------------------------------------------------------------------------------------|-----------------------------------|
| `smoothingFactor: `[Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html) | The exponential smoothing factor. |

## Public functions

### addSample

```
fun addSample(bytes: Long, durationUs: Long): Unit
```

Adds a transfer sample to the statistic.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|------------------------------------------------|
| `bytes: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)      | The number of bytes transferred.               |
| `durationUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The duration of the transfer, in microseconds. |

### getBandwidthEstimate

```
fun getBandwidthEstimate(): Long
```

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

### reset

```
fun reset(): Unit
```

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