anchor.diff:      safe_average(Vs, Cnt + 1, NewAvg).
   
   
  +derivative(Values) ->
  +    derivative(Values, null, []).
  +
  +derivative([], _Prev, Acc) ->
  +    lists:reverse(Acc);
  +derivative([{TS, Value} | Vs], null, Acc) ->
  +    derivative(Vs, Value, [{TS, null} | Acc]);
  +derivative([{TS, null} | Vs], _Prev, Acc) ->
  +    derivative(Vs, null, [{TS, null} | Acc]);
  +derivative([{TS, Value} | Vs], Prev, Acc) ->
  +    derivative(Vs, Value, [{TS, Value - Prev} | Acc]).
  +
  +
   %%
   %% TESTS
   %%
  
positive.code: evaluate_call(<<"averageBelow">>, [Series, Avg], _From, _Until, _Now) ->
      lists:filter(fun({_, Values}) -> safe_average(Values) =< Avg end, Series);
  
  evaluate_call(Unknown, _Args, _From, _Until, _Now) ->
      lager:error("unknown function call ~p or invalid arguments", [Unknown]),
      error.
  
negative.code:      ?_assertEqual(<<"test">>, alias_target(<<"foo.bar.test">>, [2])),
       ?_assertEqual(<<"test">>, alias_target(<<"foo.bar.test">>, [-1])),
       ?_assertEqual(<<"foo">>, alias_target(<<"foo.bar.test">>, [0]))
      ].
  
  pseudo_series(Series) ->
      lists:map(fun(V) -> {100, V} end, Series).
  
  derivative_test_() ->
      [?_assertEqual([], derivative([])),
       ?_assertEqual(pseudo_series([null,null,1,1,1,1,null,null,1,1]),
                     derivative(pseudo_series([null,1,2,3,4,5,null,6,7,8]))),
       ?_assertEqual(pseudo_series([null,1,2,2,2]),
                     derivative(pseudo_series([1,2,4,6,8])))
      ].
  
  safe_average_test_() ->
  