Z-scores and percentiles from LMS reference parameters, with WHO's restricted extrapolation.
- Z-score
- 1.11
- Percentile
- 87th
- Median
- 9.4 kg
Illustrative LMS parameters (L 0.2, M 9.4, S 0.11), not a published growth reference.
Installation
bunx shadcn@4.22.1 add https://organui.com/r/z-scores.jsonThis adds lib/z-scores.ts, with no dependencies.
Usage
import { formatPercentile, lmsZScore, zToPercentile } from "@/lib/z-scores"
// L, M and S for the child's age and sex, from your reference tables.
const z = lmsZScore(10.6, [0.2, 9.4, 0.11], { restricted: true }) // 1.11
formatPercentile(zToPercentile(z!)) // "87th"API Reference
| Export | Description |
|---|---|
lmsZScore(value, lms, { restricted? }) | The z-score of a measurement. restricted applies WHO's extrapolation beyond ±3 SD, which WHO uses for weight-based indicators. Null for a non-positive value. |
lmsValue(lms, z) | The measurement at a z-score, for drawing curves. |
zToPercentile(z) | The standard normal cumulative distribution as a percentile, accurate to 1.5e-7. |
percentileToZ(percentile) | The z-score of a percentile between 0 and 100. |
formatPercentile(percentile) | Ordinals such as "34th", with "<0.1st" and ">99.9th" at the ends. |
Notes
The file ships no reference data. Take L, M and S from the standard you use, such as WHO or CDC, under its terms; the growth chart's page says where to get them.
The growth chart uses this file for its z-scores and percentiles.