Smoothing

plotify.smoothing.smooth(x, y = None, temperature = 1.0)

Decription

Simple wrapper around exponential smoothing.

Returns 1 value (smoothed x) if y is None.

Returns 2 values (smoothed x and y) if y is not None.

Example
x = np.arange(100)
y = np.logspace(-50, 50)

# single value
smooth_x = plotify.smoothing.smooth(x, temperature=20.0)

# double value
smooth_x, smooth_y = plotify.smoothing.smooth(x, y)

plotify.smoothing.exponential_smoothing(x, y = None, temperature = 1.0)

Decription

Two-sided exponential moving average for smoothing a curve. It performs regular exponential moving average twice from two different sides and then combines the results together.

Arguments
  • x (ndarray/tensor/list) - x values, in accending order.
  • y (ndarray/tensor/list) - y values.
  • temperature (float, optional, default=1.0) - The higher, the smoother.
Return
  • ndarray - x values after resampling.
  • ndarray - y values after smoothing.
Credit

Adapted from OpenAI's baselines implementation.

Example
from plotify.smoothing import exponential_smoothing
x_smoothed, y_smoothed, _ = exponential_smoothing(
    x_original,
    y_original,
    temperature=3.,
)