Some checks failed
continuous-integration/drone/pr Build is failing
1. calculate age in days, weeks, and months 2. calculate body mass index for metric and english unities 3. calculate z-score for a given measurement and box-cox parameters (l, m, s) 4. calculate centile score for a given measurement and box-cox parameters
26 lines
545 B
Elixir
26 lines
545 B
Elixir
defmodule Growth.Calc.Centile do
|
|
@moduledoc """
|
|
measures =
|
|
[
|
|
[30, -1.7862, 16.9392, 0.1107],
|
|
[14, -1.3592, 20.4951, 0.12579],
|
|
[19, -1.6318, 16.049, 0.10038]
|
|
]
|
|
Enum.map(measures, &apply(Growth.Calc.Centile, :compute, &1))
|
|
"""
|
|
|
|
# TODO: (jpd) add documentation and typespecs
|
|
|
|
def compute(y, l, m, s) do
|
|
zscore = Growth.Calc.ZScore.raw(y, l, m, s)
|
|
|
|
cond do
|
|
-3 <= zscore and zscore <= 3 ->
|
|
m * :math.pow(1 + l * s * zscore, 1 / l)
|
|
|
|
true ->
|
|
:na
|
|
end
|
|
end
|
|
end
|