@hestia-earth/aggregation-engine 0.23.4 → 0.23.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/formulas/README.md +8 -1
- package/formulas/index.json +54 -3
- package/package.json +1 -1
package/formulas/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Binding token forms, matching the models format:
|
|
|
53
53
|
| `[const:365]` | a fixed literal, substituted as-is |
|
|
54
54
|
| `[display]` | documentation-only: never substitutable (e.g. a per-Cycle value that is not stored) |
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Rules learned the hard way. The tests enforce the first three; the last one no test can catch:
|
|
57
57
|
|
|
58
58
|
- **Each `$$` block owns only the glossary between it and the next block.** Several formulas sharing
|
|
59
59
|
one `Where:` list leaves the earlier ones unbound. Give each formula its own list, or combine them
|
|
@@ -61,6 +61,13 @@ Two rules the tests enforce, both learned the hard way:
|
|
|
61
61
|
- **At most one `\sum` per formula.** `renderFormula` expands a sum by treating everything after it
|
|
62
62
|
as the summand, so a sum in both numerator and denominator substitutes into malformed KaTeX.
|
|
63
63
|
Express the divisor as a scalar total (`W`) instead.
|
|
64
|
+
- **Keep symbols distinct within a doc**, `{` and `_` not being token boundaries: a bare `n` matches
|
|
65
|
+
inside `n_{k(i)}` and drags that formula's binding onto every formula containing an `n`. Use
|
|
66
|
+
`n_T`, `n_R` and so on.
|
|
67
|
+
- **Everything the divisor applies to must sit inside the summand.** The expansion is
|
|
68
|
+
`<before the sum> + <summand per row joined by " + ">`, so `\frac{1}{n} \sum_i v_i` substitutes to
|
|
69
|
+
`\frac{1}{3} (20) + (30) + (90)` — the division reaches the first row only. Write
|
|
70
|
+
`\sum_i \frac{v_i}{n}`.
|
|
64
71
|
|
|
65
72
|
Run `npm run build:formulas` after editing, and commit the regenerated `index.json` — a test fails
|
|
66
73
|
if it is stale.
|
package/formulas/index.json
CHANGED
|
@@ -112,10 +112,33 @@
|
|
|
112
112
|
}
|
|
113
113
|
],
|
|
114
114
|
"hestia_earth/aggregation/docs/general-process.md": [
|
|
115
|
+
{
|
|
116
|
+
"formula": "\\bar{v} = \\sum_i \\frac{v_i}{n_T}",
|
|
117
|
+
"section": "Number values",
|
|
118
|
+
"context": "Where no weighting structure applies, every contributor counts for the same share of the result and the mean is a simple one.",
|
|
119
|
+
"bindings": [
|
|
120
|
+
{
|
|
121
|
+
"symbol": "\\bar{v}",
|
|
122
|
+
"description": "the aggregated value, rounded to 4 significant figures",
|
|
123
|
+
"key": "value"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"symbol": "v_i",
|
|
127
|
+
"description": "the value contributed by the underlying Cycle or sub-aggregation $i$, stored for a sub-aggregation but not for a Cycle",
|
|
128
|
+
"key": "weights",
|
|
129
|
+
"column": "value"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"symbol": "n_T",
|
|
133
|
+
"description": "the number of contributors combined",
|
|
134
|
+
"key": "weights_count"
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
115
138
|
{
|
|
116
139
|
"formula": "\\bar{v} = \\sum_i v_i \\times \\frac{w_i}{W_T}",
|
|
117
140
|
"section": "Number values",
|
|
118
|
-
"context": "
|
|
141
|
+
"context": "Where a weighting structure does apply, each contributor counts for the share its weight gives it.",
|
|
119
142
|
"bindings": [
|
|
120
143
|
{
|
|
121
144
|
"symbol": "\\bar{v}",
|
|
@@ -130,7 +153,7 @@
|
|
|
130
153
|
},
|
|
131
154
|
{
|
|
132
155
|
"symbol": "w_i",
|
|
133
|
-
"description": "the weight of $i
|
|
156
|
+
"description": "the weight of $i$",
|
|
134
157
|
"key": "weights",
|
|
135
158
|
"column": "weight"
|
|
136
159
|
},
|
|
@@ -169,9 +192,37 @@
|
|
|
169
192
|
]
|
|
170
193
|
},
|
|
171
194
|
{
|
|
172
|
-
"formula": "\\bar{v} = \\sum_i
|
|
195
|
+
"formula": "\\bar{v} = \\sum_i \\frac{v_i}{n_R + n_Z}",
|
|
173
196
|
"section": "Completeness",
|
|
174
197
|
"context": "This zero-filling is what allows a term reported by only part of the population to be averaged over the whole population rather than only where it occurs.",
|
|
198
|
+
"bindings": [
|
|
199
|
+
{
|
|
200
|
+
"symbol": "\\bar{v}",
|
|
201
|
+
"description": "the aggregated value",
|
|
202
|
+
"key": "value"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"symbol": "v_i",
|
|
206
|
+
"description": "the value reported for the term, stored for a sub-aggregation but not for a Cycle",
|
|
207
|
+
"key": "reporting",
|
|
208
|
+
"column": "value"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"symbol": "n_R",
|
|
212
|
+
"description": "the number of Cycles or sub-aggregations that report the term",
|
|
213
|
+
"key": "reporting_count"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"symbol": "n_Z",
|
|
217
|
+
"description": "the number of them that are complete for the area but report no value",
|
|
218
|
+
"key": "zero_filled_count"
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"formula": "\\bar{v} = \\sum_i v_i \\times \\frac{w_i}{W_R + W_Z}",
|
|
224
|
+
"section": "Completeness",
|
|
225
|
+
"context": "Where a weighting structure applies, the same split is made over the weights rather than the counts.",
|
|
175
226
|
"bindings": [
|
|
176
227
|
{
|
|
177
228
|
"symbol": "\\bar{v}",
|