This commit is contained in:
chaos 2024-11-09 13:36:43 +00:00
parent 89ca945961
commit bfc7912236

View file

@ -13,14 +13,13 @@ def ingestionDose($customUnits):
.dose .dose
end; end;
# this probably isnt right
def addStandardDeviations($expectationX; $standardDeviationX; $expectationY; $standardDeviationY): def addStandardDeviations($expectationX; $standardDeviationX; $expectationY; $standardDeviationY):
(pow($standardDeviationX; 2) + pow($expectationX; 2)) as $sumX | (pow($standardDeviationX; 2) + pow($expectationX; 2)) as $sumX |
(pow($standardDeviationY; 2) + pow($expectationY; 2)) as $sumY | (pow($standardDeviationY; 2) + pow($expectationY; 2)) as $sumY |
(pow($expectationX; 2) * pow($expectationY; 2)) as $expectations | (pow($expectationX; 2) * pow($expectationY; 2)) as $expectations |
($sumX * $sumY - $expectations) as $productVariance | ($sumX * $sumY - $expectations) as $productVariance |
if $productVariance > 0.0000001 then if $productVariance > 0.0000001 then
$productVariance | debug | sqrt $productVariance | sqrt
else else
null null
end; end;
@ -32,7 +31,7 @@ def ingestionStandardDeviation($customUnits):
if .customUnitId != null then if .customUnitId != null then
($customUnits | map(select(.id == $ingestion.customUnitId))[0]) as $customUnit | ($customUnits | map(select(.id == $ingestion.customUnitId))[0]) as $customUnit |
($ingestion | ingestionDose($customUnits) // 0) as $expectationX | ($ingestion.dose // 0) as $expectationX |
($ingestion.estimatedDoseStandardDeviation // 0) as $standardDeviationX | ($ingestion.estimatedDoseStandardDeviation // 0) as $standardDeviationX |
($customUnit.dose // 0) as $expectationY | ($customUnit.dose // 0) as $expectationY |
($customUnit.estimatedDoseStandardDeviation // 0) as $standardDeviationY | ($customUnit.estimatedDoseStandardDeviation // 0) as $standardDeviationY |
@ -126,7 +125,8 @@ def ingestionInfo($customUnits):
end | end |
.unit |= $unit | .unit |= $unit |
.dose += $dose; .dose |= $dose |
.standardDeviation |= $standardDeviation;
def addIngestionInfo($rhs): def addIngestionInfo($rhs):
. as $lhs | . as $lhs |
@ -144,7 +144,8 @@ def addIngestionInfo($rhs):
.isEstimate |= true .isEstimate |= true
end | end |
.dose += $rhs.dose; .dose += $rhs.dose |
.standardDeviation += $rhs.standardDeviation;
def addIngestionInfos: def addIngestionInfos:
. as $ingestionInfos | . as $ingestionInfos |