crawlie v1.0.0 Crawlie.Stats.Distribution
Summary
Functions
Adds a value to the bucket in the distribution under the given key
Adds “missing” keys to the distribution for convenience and stuff
Converts the distribution from absolute numbers to proportions or probability distribution if you will
Removes a value from the bucket in the distribution under the given key
Functions
Adds a value to the bucket in the distribution under the given key.
Example
iex> alias Crawlie.Stats.Distribution
iex> stats = %{numbers: %{}, enums: %{}}
iex> stats
...> |> Distribution.add(:numbers, 3)
...> |> Distribution.add(:enums, :foo)
%{numbers: %{3 => 1}, enums: %{foo: 1}}
Adds “missing” keys to the distribution for convenience and stuff.
Example
iex> alias Crawlie.Stats.Distribution
iex> dist = %{2 => 15, 3 => 10}
iex> Distribution.normalize(dist, 0..4)
%{0 => 0, 1 => 0, 2 => 15, 3 => 10, 4 => 0}
Converts the distribution from absolute numbers to proportions or probability distribution if you will.
Example
iex> alias Crawlie.Stats.Distribution
iex> dist = %{1 => 2, 2 => 0, 3 => 3}
iex> Distribution.proportions(dist)
%{1 => 0.4, 2 => 0.0, 3 => 0.6}