def ema(n=10, wilder=false) # rubocop:disable Metrics/AbcSize
          smoother = wilder ? 1.0 / n : 2.0 / (n + 1)
          # need to start everything from the first non-nil observation
          start = @data.index { |i| !i.nil? }
          # first n - 1 observations are nil
          base = [nil] * (start + n - 1)
          # nth observation is just a moving average
          base << @data[start...(start + n)].inject(0.0) { |s, a| a.nil? ? s : s + a } / n
          (start + n).upto size - 1 do |i|
            base << self[i] * smoother + (1 - smoother) * base.last
          end

          Daru::Vector.new(base, index: @index, name: @name)
        end
Exponential Moving Average.
Calculates an exponential moving average of the series using a
specified parameter. If wilder is false (the default) then the EMA
uses a smoothing value of 2 / (n + 1), if it is true then it uses the
Welles Wilder smoother of 1 / n.

Warning for EMA usage: EMAs are unstable for small series, as they
use a lot more than n observations to calculate. The series is stable
if the size of the series is >= 3.45 * (n + 1)

@param [Integer] n (10) Loopback length.
@param [TrueClass, FalseClass] wilder (false) If true, 1/n value is
used for smoothing; if false, uses 2/(n+1) value

@example Using ema

ts = Daru::Vector.new((1..100).map { rand })
# => [0.577..., 0.123..., 0.173..., 0.233..., ...]

# first 9 observations are nil
ts.ema   # => [ ... nil, 0.455... , 0.395..., 0.323..., ... ]

@return [Daru::Vector] Contains EMA