ex_trainer/lib/growth/calc/centile.ex
Joao P Dubas bb79aa2f3a
Some checks failed
continuous-integration/drone/pr Build is failing
fix(growth): alias z-score and use if
2024-06-06 11:34:02 +00:00

26 lines
540 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))
"""
alias Growth.Calc.ZScore
# TODO: (jpd) add documentation and typespecs
def compute(y, l, m, s) do
zscore = ZScore.raw(y, l, m, s)
if -3 <= zscore and zscore <= 3 do
m * :math.pow(1 + l * s * zscore, 1 / l)
else
:na
end
end
end