chore(growth): add documentation and examples
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
@@ -1,18 +1,39 @@
|
||||
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))
|
||||
Calculate percentile for a given measurement and the fitted values of Box-Cox by age/height:
|
||||
|
||||
* power
|
||||
* median
|
||||
* coefficientof variation
|
||||
|
||||
This calculation is described in the [instructions provided by the World Health Organization](https://cdn.who.int/media/docs/default-source/child-growth/growth-reference-5-19-years/computation.pdf).
|
||||
|
||||
## Examples:
|
||||
|
||||
iex> measures =
|
||||
...> [
|
||||
...> [30, -1.7862, 16.9392, 0.1107],
|
||||
...> [14, -1.3592, 20.4951, 0.12579],
|
||||
...> [19, -1.6318, 16.049, 0.10038]
|
||||
...> ]
|
||||
iex> Enum.map(measures, &apply(Growth.Calc.Centile, :compute, &1))
|
||||
[:na, :na, 19.0]
|
||||
|
||||
"""
|
||||
|
||||
alias Growth.Calc.ZScore
|
||||
|
||||
# TODO: (jpd) add documentation and typespecs
|
||||
@spec compute(number(), number(), number(), number()) :: number()
|
||||
@doc """
|
||||
Compute the centile for a given measurement (`y`) and the Box-Cox values: power (`l`), median (`m`), and
|
||||
coefficient of variation (`s`).
|
||||
|
||||
## Examples:
|
||||
|
||||
iex> Growth.Calc.Centile.compute(19, -1.6318, 16.049, 0.10038)
|
||||
19.0
|
||||
|
||||
"""
|
||||
def compute(y, l, m, s) do
|
||||
zscore = ZScore.raw(y, l, m, s)
|
||||
|
||||
|
Reference in New Issue
Block a user