class_docstr: Injects random trend changes into a time series.
  
  At a high level, the transform tracks the velocity (trend) of a time series
  and then, when injecting a trend change at a particular time, it scales
  the current velocity by a random factor. The disturbance to the velocity is 
  persisted to values in the near future, thus emulating a sudden change of trend.
  
  Let, ``(a,b)`` be the scale range. If the first trend change happens at time ``t*``, 
  it is injected as follows:
  
  .. math::
      \tilde{y}_{t^*} = y_{t^*-1} + v_{t^*} + \Delta v_{t^*} \\
      \begin{align*}
      \text{where } & \Delta v_{t^*} = Sign \times Z \times v_{t^*}, \\
      & v_{t^*} = y_{t^*} - y_{t^*-1}
      & Z \sim Unif(a,b), \\
      & Sign \text{ is a random sign} \\
      \end{align*}
  
  Afterward, the trend change is persisted and ``y_t`` (for ``t > t*``) is changed as follows:
  
  .. math::
      \tilde{y}_{t} = \tilde{y}_{t-1} + v_t + \beta \times \Delta v_{t^*}
code: def _anomalize_univariate(self, var: UnivariateTimeSeries):
      vels = [0] + var.diff()[1:].tolist()
      emv = pd.Series(vels).ewm(alpha=self.alpha, adjust=False).mean()
      new_vals, labels = [], []
  
      x_prev, v_delta = var.values[0], vels[0]
      for v, mv in zip(vels, emv):
          is_anom = self.random_is_anom()
          v_delta = (
              self.random_scale() * mv
              if is_anom
              else self.beta * v_delta
          )
          x = x_prev + v + v_delta
          new_vals.append(x)
          labels.append(is_anom)
          x_prev = x
  
      anomalized_var = UnivariateTimeSeries(
          var.time_stamps, new_vals, var.name
      )
      labels_var = UnivariateTimeSeries(
          var.time_stamps, labels, "anomaly"
      )
  
      return anomalized_var, labels_var
  
imports: from abc import abstractmethod
  from typing import Tuple
  import numpy
  import pandas
  from merlion.transform.base import Identity, TransformBase
  from merlion.transform.bound import LowerUpperClip
  from merlion.utils.time_series import UnivariateTimeSeries, TimeSeries
label_desc: Use image node_id 5 for calling the TrendChange obj's underlying member method code with example usage: obj._anomalize_univariate(var) and returns: anomalized_var,  labels_var