Indicado.EMA.eval

You're seeing just the function eval, go back to Indicado.EMA module for more information.

Specs

eval([list(), ...], pos_integer()) :: {:ok, [float(), ...] | {:error, atom()}}

Calculates EMA for the list. It needs non empty list of numbers and a positive period argument.

Returns {:ok, ema_list} or {:error, reason}

Examples

iex> Indicado.EMA.eval([1, 2, 3, 4], 2)
{:ok, [1.0, 1.6666666666666665, 2.5555555555555554, 3.518518518518518]}

iex> Indicado.EMA.eval([2, 4, 5, 10, 100, 1000], 3)
{:ok, [2.0, 3.0, 4.0, 7.0, 53.5, 526.75]}

iex> Indicado.EMA.eval([2, 4, 5, 10, 100, 1000], 5)
{:ok, [2.0, 2.666666666666667, 3.4444444444444446, 5.62962962962963, 37.08641975308642, 358.0576131687243]}

iex> Indicado.EMA.eval([], 2)
{:error, :not_enough_data}

iex> Indicado.EMA.eval([1, 2, 3, 4], 0)
{:error, :bad_period}