prop/lib/microwaveprop/rover/aggregator.ex

20 lines
608 B
Elixir

defmodule Microwaveprop.Rover.Aggregator do
@moduledoc """
Combine per-station link margins into a single per-cell quality
number using the rover formula `0.7·max + 0.3·mean`. Nil entries
are dropped before aggregation; an empty (or fully-nil) list
returns nil.
"""
@spec cell_margin_db([float() | nil]) :: float() | nil
def cell_margin_db([]), do: nil
def cell_margin_db(margins) when is_list(margins) do
valid = Enum.reject(margins, &is_nil/1)
case valid do
[] -> nil
values -> 0.7 * Enum.max(values) + 0.3 * (Enum.sum(values) / length(values))
end
end
end