From bb79aa2f3a2800cfd9c24af8c6569b09e31ebdfd Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Thu, 6 Jun 2024 11:34:02 +0000 Subject: [PATCH] fix(growth): alias z-score and use if --- lib/growth/calc/centile.ex | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/growth/calc/centile.ex b/lib/growth/calc/centile.ex index ea48020..91c6ba6 100644 --- a/lib/growth/calc/centile.ex +++ b/lib/growth/calc/centile.ex @@ -9,17 +9,17 @@ defmodule Growth.Calc.Centile do 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 = Growth.Calc.ZScore.raw(y, l, m, s) + zscore = ZScore.raw(y, l, m, s) - cond do - -3 <= zscore and zscore <= 3 -> - m * :math.pow(1 + l * s * zscore, 1 / l) - - true -> - :na + if -3 <= zscore and zscore <= 3 do + m * :math.pow(1 + l * s * zscore, 1 / l) + else + :na end end end