wip(growth): calculate key metrics for growth
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
This commit is contained in:
2024-06-06 01:33:06 +00:00
parent 8be9fa38bb
commit 500d0e89bb
4 changed files with 141 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
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