code: def fit_model(ts, sc=None):
      
      assert sc != None, "Missing SparkContext"
  
      jvm = sc._jvm
      jmodel = jvm.com.cloudera.sparkts.models.EWMA.fitModel(_py2java(sc, Vectors.dense(ts)))
      return EWMAModel(jmodel=jmodel, sc=sc)
docs: Fits an EWMA model to a time series. Uses the first point in the time series as a starting
      value. Uses sum squared error as an objective function to optimize to find smoothing parameter
      The model for EWMA is recursively defined as S_t = (1 - a) * X_t + a * S_{t-1}, where
      a is the smoothing parameter, X is the original series, and S is the smoothed series
      Note that the optimization is performed as unbounded optimization, although in its formal
      definition the smoothing parameter is <= 1, which corresponds to an inequality bounded
      optimization. Given this, the resulting smoothing parameter should always be sanity checked
      https://en.wikipedia.org/wiki/Exponential_smoothing
      
      Parameters
      ----------
      ts:
          the time series to which we want to fit an EWMA model as a Numpy array
          
      Returns an EWMA model