Skip to content

Class: EwmaEstimator ​

Defined in: EwmaEstimator.ts:16

Exponential Weighted Moving Average (EWMA) throughput estimator based on 2 half-lives

Example ​

ts
const estimator = new EwmaEstimator({ fastHalfLife: 2, slowHalfLife: 5 })

// 500 bps
estimator.sample({
	startTime: 0,
	encodedBodySize: 125,
	duration: 2000,
})

// 250 bps
estimator.sample({
	startTime: 2000,
	encodedBodySize: 125,
	duration: 4000,
})

equal(estimator.getEstimate(), 285)

Implements ​

Constructors ​

Constructor ​

ts
new EwmaEstimator(options): EwmaEstimator;

Defined in: EwmaEstimator.ts:25

Parameters ​

options ​

EwmaEstimatorOptions

Returns ​

EwmaEstimator

Methods ​

getEstimate() ​

ts
getEstimate(): number;

Defined in: EwmaEstimator.ts:50

Returns the current estimate of the throughput (in bits per second)

Returns ​

number

The current estimate of the throughput

Implementation of ​

ThroughputEstimator.getEstimate


sample() ​

ts
sample(sample): void;

Defined in: EwmaEstimator.ts:34

Adds a sample to the throughput estimator. The estimator ignores a sample with an encodedBodySize or a duration at or below 0, NaN, or Infinity.

Parameters ​

sample ​

ResourceTiming

The timing sample to add

Returns ​

void

Implementation of ​

ThroughputEstimator.sample

A Streaming Video Technology Alliance project.