On Github pacharanero / letsmakeehealthservices
bmi = weight_in_kg / ( height_in_m ** 2 )
def lms_to_centile(x, lms) # formulae taken from http://www.cdc.gov/growthcharts/percentile_data_files.htm # x is the measurement under consideration # returns the percentile as a number from 0 to 100 # for more information about generating centile values in code, see this blog post: http://www.bawmedical.co.uk/2014/05/10/centiles-doing-them-in-code-part-1/ l = lms[:l] m = lms[:m] s = lms[:s] if l == 0 z = log(x / m) / s else z = (((x / m)**l) - 1) / (l * s) end Distribution::Normal.cdf(z) * 100 end
"bmi": { "0": { "l": -0.233, "m": 13.281, "s": 0.0926 }, "1": { "l": -0.398, "m": 14.953, "s": 0.0872 }, "2": { "l": -0.512, "m": 16.137, "s": 0.0836 }, "3": { "l": -0.589, "m": 16.844, "s": 0.0813 }, "4": { "l": -0.641, "m": 17.258, "s": 0.0799 }, "5": { "l": -0.676, "m": 17.51, "s": 0.079 }, "6": { "l": -0.698, "m": 17.666, "s": 0.0784 }, "7": { "l": -0.711, "m": 17.758, "s": 0.078 }, "8": { "l": -0.718, "m": 17.798, "s": 0.0777 }, "9": { "l": -0.72, "m": 17.797, "s": 0.0775 }, "10": { "l": -0.72, "m": 17.763, "s": 0.0774 }, "11": { "l": -0.718, "m": 17.709, "s": 0.0773 }, "12": { "l": -0.717, "m": 17.644, "s": 0.0774 }, "13": { "l": -0.716, "m": 17.572, "s": 0.0774 }, "14": { "l": -0.716, "m": 17.492, "s": 0.0776 }, "15": { "l": -0.718, "m": 17.406, "s": 0.0777 }, "16": { "l": -0.721, "m": 17.316, "s": 0.0779 }, "17": { "l": -0.726, "m": 17.223, "s": 0.0781 }, "18": { "l": -0.733, "m": 17.131, "s": 0.0783 }, "19": { "l": -0.742, "m": 17.04, "s": 0.0785 }, "20": { "l": -0.753, "m": 16.953, "s": 0.0786 }, "21": { "l": -0.766, "m": 16.87, "s": 0.0787 }, "22": { "l": -0.781, "m": 16.793, "s": 0.0788 }, "23": { "l": -0.797, "m": 16.721, "s": 0.0788 }, "24": { "l": -0.814, "m": 16.655, "s": 0.0788 }, "25": { "l": -0.832, "m": 16.595, "s": 0.0788 }, "26": { "l": -0.851, "m": 16.539, "s": 0.0788 }, "27": { "l": -0.871, "m": 16.488, "s": 0.0787 }, "28": { "l": -0.891, "m": 16.441, "s": 0.0787 }, "29": { "l": -0.912, "m": 16.397, "s": 0.0786 }, "30": { "l": -0.933, "m": 16.355, "s": 0.0785 }, "31": { "l": -0.954, "m": 16.315, "s": 0.0784 }, "32": { "l": -0.975, "m": 16.276, "s": 0.0783 }, "33": { "l": -0.996, "m": 16.239, "s": 0.0781 }, "34": { "l": -1.018, "m": 16.203, "s": 0.078 }, "35": { "l": -1.039, "m": 16.168, "s": 0.0779 }, "36": { "l": -1.06, "m": 16.133, "s": 0.0777 }, "37": { "l": -1.08, "m": 16.099, "s": 0.0776 }, "38": { "l": -1.101, "m": 16.065, "s": 0.0774 }, "39": { "l": -1.121, "m": 16.031, "s": 0.0773 }, "40": { "l": -1.141, "m": 15.997, "s": 0.0772 }, "41": { "l": -1.161, "m": 15.963, "s": 0.0771 }, "42": { "l": -1.181, "m": 15.93, "s": 0.077 }, "43": { "l": -1.2, "m": 15.898, "s": 0.0769 }, "44": { "l": -1.219, "m": 15.867, "s": 0.0769 }, "45": { "l": -1.237, "m": 15.836, "s": 0.0768 }, "46": { "l": -1.256, "m": 15.807, "s": 0.0768 }, "47": { "l": -1.273, "m": 15.779, "s": 0.0768 }, "48": { "l": -1.291, "m": 15.752, "s": 0.0768 }, "49": { "l": -1.309, "m": 15.727, "s": 0.0769 }, "50": { "l": -1.325, "m": 15.704, "s": 0.0769 }, "51": { "l": -1.342, "m": 15.682, "s": 0.077 }, "52": { "l": -1.359, "m": 15.662, "s": 0.0771 }, "53": { "l": -1.375, "m": 15.644, "s": 0.0772 }, "54": { "l": -1.391, "m": 15.626, "s": 0.0773 }, "55": { "l": -1.407, "m": 15.61, "s": 0.0775 }, "56": { "l": -1.422, "m": 15.595, "s": 0.0777 }, "57": { "l": -1.437, "m": 15.582, "s": 0.0778 }, "58": { "l": -1.452, "m": 15.569, "s": 0.0781 }, "59": { "l": -1.467, "m": 15.557, "s": 0.0783 }, "60": { "l": -1.481, "m": 15.547, "s": 0.0786 }, "61": { "l": -1.495, "m": 15.538, "s": 0.0788 }, "62": { "l": -1.509, "m": 15.53, "s": 0.0792 }, "63": { "l": -1.523, "m": 15.523, "s": 0.0795 }, "64": { "l": -1.536, "m": 15.517, "s": 0.0798 }, "65": { "l": -1.549, "m": 15.511, "s": 0.0802 }, "66": { "l": -1.562, "m": 15.507, "s": 0.0806 }, "67": { "l": -1.575, "m": 15.503, "s": 0.081 }, "68": { "l": -1.587, "m": 15.5, "s": 0.0814 }, "69": { "l": -1.599, "m": 15.498, "s": 0.0819 }, "70": { "l": -1.611, "m": 15.497, "s": 0.0824 }, "71": { "l": -1.622, "m": 15.497, "s": 0.0828 }, "72": { "l": -1.634, "m": 15.498, "s": 0.0833 }, "73": { "l": -1.644, "m": 15.499, "s": 0.0839 }, "74": { "l": -1.655, "m": 15.501, "s": 0.0844 }, "75": { "l": -1.665, "m": 15.503, "s": 0.0849 }, "76": { "l": -1.675, "m": 15.507, "s": 0.0855 }, "77": { "l": -1.685, "m": 15.511, "s": 0.0861 }, "78": { "l": -1.694, "m": 15.516, "s": 0.0866 }, "79": { "l": -1.704, "m": 15.522, "s": 0.0872 }, "80": { "l": -1.713, "m": 15.529, "s": 0.0878 }, "81": { "l": -1.721, "m": 15.536, "s": 0.0884 }, "82": { "l": -1.73, "m": 15.545, "s": 0.089 }, "83": { "l": -1.738, "m": 15.554, "s": 0.0896 }, "84": { "l": -1.745, "m": 15.564, "s": 0.0902 }, "85": { "l": -1.753, "m": 15.575, "s": 0.0908 }, "86": { "l": -1.76, "m": 15.587, "s": 0.0915 }, "87": { "l": -1.767, "m": 15.6, "s": 0.0921 }, "88": { "l": -1.774, "m": 15.614, "s": 0.0927 }, "89": { "l": -1.781, "m": 15.628, "s": 0.0933 }, "90": { "l": -1.787, "m": 15.643, "s": 0.0939 }, "91": { "l": -1.793, "m": 15.659, "s": 0.0945 }, "92": { "l": -1.798, "m": 15.675, "s": 0.0951 }, "93": { "l": -1.804, "m": 15.692, "s": 0.0957 }, "94": { "l": -1.809, "m": 15.71, "s": 0.0963 }, "95": { "l": -1.814, "m": 15.729, "s": 0.0969 }, "96": { "l": -1.818, "m": 15.748, "s": 0.0975 }, "97": { "l": -1.823, "m": 15.768, "s": 0.0981 }, "98": { "l": -1.827, "m": 15.789, "s": 0.0986 }, "99": { "l": -1.83, "m": 15.81, "s": 0.0992 }, "100": { "l": -1.834, "m": 15.833, "s": 0.0998 }, "101": { "l": -1.837, "m": 15.855, "s": 0.1003 }, "102": { "l": -1.84, "m": 15.88, "s": 0.1008 }, "103": { "l": -1.843, "m": 15.904, "s": 0.1014 }, "104": { "l": -1.846, "m": 15.929, "s": 0.1019 }, "105": { "l": -1.848, "m": 15.955, "s": 0.1024 }, "106": { "l": -1.85, "m": 15.982, "s": 0.1029 }, "107": { "l": -1.852, "m": 16.009, "s": 0.1034 }, "108": { "l": -1.854, "m": 16.037, "s": 0.1039 }, "109": { "l": -1.855, "m": 16.066, "s": 0.1044 }, "110": { "l": -1.856, "m": 16.095, "s": 0.1048 }, "111": { "l": -1.857, "m": 16.125, "s": 0.1053 }, "112": { "l": -1.858, "m": 16.155, "s": 0.1057 }, "113": { "l": -1.858, "m": 16.187, "s": 0.1062 }, "114": { "l": -1.859, "m": 16.219, "s": 0.1066 }, "115": { "l": -1.859, "m": 16.251, "s": 0.107 }, "116": { "l": -1.859, "m": 16.284, "s": 0.1074 }, "117": { "l": -1.859, "m": 16.318, "s": 0.1078 }, "118": { "l": -1.859, "m": 16.352, "s": 0.1082 }, "119": { "l": -1.858, "m": 16.387, "s": 0.1085 }, "120": { "l": -1.857, "m": 16.423, "s": 0.1089 }, "121": { "l": -1.856, "m": 16.459, "s": 0.1092 }, "122": { "l": -1.855, "m": 16.496, "s": 0.1096 }, "123": { "l": -1.854, "m": 16.533, "s": 0.1099 }, "124": { "l": -1.853, "m": 16.57, "s": 0.1102 }, "125": { "l": -1.851, "m": 16.609, "s": 0.1105 }, "126": { "l": -1.85, "m": 16.648, "s": 0.1108 }, "127": { "l": -1.848, "m": 16.687, "s": 0.1111 }, "128": { "l": -1.846, "m": 16.727, "s": 0.1114 }, "129": { "l": -1.844, "m": 16.768, "s": 0.1117 }, "130": { "l": -1.842, "m": 16.808, "s": 0.112 }, "131": { "l": -1.839, "m": 16.85, "s": 0.1122 }, "132": { "l": -1.837, "m": 16.892, "s": 0.1125 }, "133": { "l": -1.834, "m": 16.935, "s": 0.1127 }, "134": { "l": -1.831, "m": 16.977, "s": 0.113 }, "135": { "l": -1.829, "m": 17.02, "s": 0.1132 }, "136": { "l": -1.826, "m": 17.065, "s": 0.1134 }, "137": { "l": -1.823, "m": 17.108, "s": 0.1136 }, "138": { "l": -1.819, "m": 17.154, "s": 0.1138 }, "139": { "l": -1.816, "m": 17.199, "s": 0.114 }, "140": { "l": -1.813, "m": 17.244, "s": 0.1142 }, "141": { "l": -1.809, "m": 17.291, "s": 0.1144 }, "142": { "l": -1.806, "m": 17.338, "s": 0.1146 }, "143": { "l": -1.802, "m": 17.386, "s": 0.1147 }, "144": { "l": -1.799, "m": 17.433, "s": 0.1149 }, "145": { "l": -1.795, "m": 17.481, "s": 0.115 }, "146": { "l": -1.791, "m": 17.53, "s": 0.1152 }, "147": { "l": -1.787, "m": 17.579, "s": 0.1153 }, "148": { "l": -1.783, "m": 17.629, "s": 0.1155 }, "149": { "l": -1.78, "m": 17.679, "s": 0.1156 }, "150": { "l": -1.776, "m": 17.729, "s": 0.1157 }, "151": { "l": -1.771, "m": 17.779, "s": 0.1158 }, "152": { "l": -1.767, "m": 17.83, "s": 0.1159 }, "153": { "l": -1.763, "m": 17.881, "s": 0.116 }, "154": { "l": -1.759, "m": 17.933, "s": 0.1161 }, "155": { "l": -1.755, "m": 17.985, "s": 0.1162 }, "156": { "l": -1.75, "m": 18.037, "s": 0.1163 }, "157": { "l": -1.746, "m": 18.089, "s": 0.1164 }, "158": { "l": -1.742, "m": 18.142, "s": 0.1165 }, "159": { "l": -1.738, "m": 18.194, "s": 0.1166 }, "160": { "l": -1.733, "m": 18.247, "s": 0.1166 }, "161": { "l": -1.729, "m": 18.3, "s": 0.1167 }, "162": { "l": -1.724, "m": 18.354, "s": 0.1167 }, "163": { "l": -1.72, "m": 18.407, "s": 0.1168 }, "164": { "l": -1.715, "m": 18.46, "s": 0.1169 }, "165": { "l": -1.711, "m": 18.514, "s": 0.1169 }, "166": { "l": -1.707, "m": 18.567, "s": 0.117 }, "167": { "l": -1.702, "m": 18.621, "s": 0.117 }, "168": { "l": -1.697, "m": 18.675, "s": 0.117 }, "169": { "l": -1.693, "m": 18.729, "s": 0.1171 }, "170": { "l": -1.689, "m": 18.783, "s": 0.1171 }, "171": { "l": -1.684, "m": 18.836, "s": 0.1171 }, "172": { "l": -1.68, "m": 18.89, "s": 0.1172 }, "173": { "l": -1.675, "m": 18.944, "s": 0.1172 }, "174": { "l": -1.671, "m": 18.997, "s": 0.1172 }, "175": { "l": -1.666, "m": 19.051, "s": 0.1172 }, "176": { "l": -1.661, "m": 19.104, "s": 0.1172 }, "177": { "l": -1.657, "m": 19.158, "s": 0.1172 }, "178": { "l": -1.652, "m": 19.211, "s": 0.1172 }, "179": { "l": -1.648, "m": 19.264, "s": 0.1172 }, "180": { "l": -1.643, "m": 19.317, "s": 0.1173 }, "181": { "l": -1.639, "m": 19.37, "s": 0.1173 }, "182": { "l": -1.635, "m": 19.423, "s": 0.1173 }, "183": { "l": -1.63, "m": 19.475, "s": 0.1172 }, "184": { "l": -1.626, "m": 19.528, "s": 0.1172 }, "185": { "l": -1.621, "m": 19.579, "s": 0.1172 }, "186": { "l": -1.617, "m": 19.632, "s": 0.1172 }, "187": { "l": -1.612, "m": 19.683, "s": 0.1172 }, "188": { "l": -1.608, "m": 19.735, "s": 0.1172 }, "189": { "l": -1.603, "m": 19.786, "s": 0.1172 }, "190": { "l": -1.599, "m": 19.837, "s": 0.1172 }, "191": { "l": -1.595, "m": 19.887, "s": 0.1171 }, "192": { "l": -1.59, "m": 19.938, "s": 0.1171 }, "193": { "l": -1.586, "m": 19.988, "s": 0.1171 }, "194": { "l": -1.582, "m": 20.038, "s": 0.1171 }, "195": { "l": -1.577, "m": 20.087, "s": 0.1171 }, "196": { "l": -1.573, "m": 20.137, "s": 0.117 }, "197": { "l": -1.569, "m": 20.186, "s": 0.117 }, "198": { "l": -1.564, "m": 20.234, "s": 0.117 }, "199": { "l": -1.56, "m": 20.282, "s": 0.117 }, "200": { "l": -1.556, "m": 20.33, "s": 0.1169 }, "201": { "l": -1.551, "m": 20.378, "s": 0.1169 }, "202": { "l": -1.547, "m": 20.425, "s": 0.1169 }, "203": { "l": -1.543, "m": 20.472, "s": 0.1168 }, "204": { "l": -1.538, "m": 20.519, "s": 0.1168 }, "205": { "l": -1.534, "m": 20.565, "s": 0.1168 }, "206": { "l": -1.53, "m": 20.611, "s": 0.1167 }, "207": { "l": -1.526, "m": 20.656, "s": 0.1167 }, "208": { "l": -1.521, "m": 20.702, "s": 0.1167 }, "209": { "l": -1.517, "m": 20.746, "s": 0.1166 }, "210": { "l": -1.513, "m": 20.791, "s": 0.1166 }, "211": { "l": -1.509, "m": 20.836, "s": 0.1166 }, "212": { "l": -1.505, "m": 20.879, "s": 0.1165 }, "213": { "l": -1.501, "m": 20.923, "s": 0.1165 }, "214": { "l": -1.496, "m": 20.967, "s": 0.1165 }, "215": { "l": -1.492, "m": 21.009, "s": 0.1164 }, "216": { "l": -1.488, "m": 21.052, "s": 0.1164 }, "217": { "l": -1.484, "m": 21.095, "s": 0.1164 }, "218": { "l": -1.48, "m": 21.136, "s": 0.1163 }, "219": { "l": -1.476, "m": 21.178, "s": 0.1163 }, "220": { "l": -1.472, "m": 21.22, "s": 0.1162 }, "221": { "l": -1.467, "m": 21.26, "s": 0.1162 }, "222": { "l": -1.463, "m": 21.301, "s": 0.1162 }, "223": { "l": -1.459, "m": 21.342, "s": 0.1161 }, "224": { "l": -1.455, "m": 21.382, "s": 0.1161 }, "225": { "l": -1.451, "m": 21.422, "s": 0.1161 }, "226": { "l": -1.447, "m": 21.461, "s": 0.116 }, "227": { "l": -1.443, "m": 21.501, "s": 0.116 }, "228": { "l": -1.439, "m": 21.54, "s": 0.1159 }, "229": { "l": -1.435, "m": 21.578, "s": 0.1159 }, "230": { "l": -1.431, "m": 21.617, "s": 0.1159 }, "231": { "l": -1.427, "m": 21.655, "s": 0.1158 }, "232": { "l": -1.423, "m": 21.693, "s": 0.1158 }, "233": { "l": -1.419, "m": 21.73, "s": 0.1158 }, "234": { "l": -1.415, "m": 21.768, "s": 0.1157 }, "235": { "l": -1.412, "m": 21.805, "s": 0.1157 }, "236": { "l": -1.408, "m": 21.842, "s": 0.1157 }, "237": { "l": -1.404, "m": 21.878, "s": 0.1156 }, "238": { "l": -1.4, "m": 21.914, "s": 0.1156 }, "239": { "l": -1.396, "m": 21.951, "s": 0.1155 }, "240": { "l": -1.392, "m": 21.986, "s": 0.1155 }, "241": { "l": -1.388, "m": 22.022, "s": 0.1155 }, "242": { "l": -1.385, "m": 22.058, "s": 0.1154 }, "243": { "l": -1.381, "m": 22.093, "s": 0.1154 }, "244": { "l": -1.377, "m": 22.128, "s": 0.1154 }, "245": { "l": -1.373, "m": 22.162, "s": 0.1153 }, "246": { "l": -1.369, "m": 22.197, "s": 0.1153 }, "247": { "l": -1.366, "m": 22.231, "s": 0.1153 }, "248": { "l": -1.362, "m": 22.266, "s": 0.1152 }, "249": { "l": -1.358, "m": 22.299, "s": 0.1152 }, "250": { "l": -1.354, "m": 22.333, "s": 0.1152 }, "251": { "l": -1.351, "m": 22.367, "s": 0.1151 }, "252": { "l": -1.347, "m": 22.4, "s": 0.1151 }, "253": { "l": -1.343, "m": 22.433, "s": 0.1151 }, "254": { "l": -1.34, "m": 22.467, "s": 0.115 }, "255": { "l": -1.336, "m": 22.499, "s": 0.115 }, "256": { "l": -1.332, "m": 22.532, "s": 0.115 }, "257": { "l": -1.329, "m": 22.565, "s": 0.1149 }, "258": { "l": -1.325, "m": 22.597, "s": 0.1149 }, "259": { "l": -1.322, "m": 22.629, "s": 0.1149 }, "260": { "l": -1.318, "m": 22.662, "s": 0.1148 }, "261": { "l": -1.314, "m": 22.693, "s": 0.1148 }, "262": { "l": -1.311, "m": 22.725, "s": 0.1148 }, "263": { "l": -1.307, "m": 22.757, "s": 0.1147 }, "264": { "l": -1.304, "m": 22.788, "s": 0.1147 }, "265": { "l": -1.3, "m": 22.82, "s": 0.1147 }, "266": { "l": -1.297, "m": 22.851, "s": 0.1146 }, "267": { "l": -1.293, "m": 22.882, "s": 0.1146 }, "268": { "l": -1.29, "m": 22.913, "s": 0.1146 }, "269": { "l": -1.286, "m": 22.945, "s": 0.1146 }, "270": { "l": -1.283, "m": 22.975, "s": 0.1145 }, "271": { "l": -1.279, "m": 23.005, "s": 0.1145 }, "272": { "l": -1.276, "m": 23.036, "s": 0.1145 }, "273": { "l": -1.272, "m": 23.067, "s": 0.1144 }, "274": { "l": -1.269, "m": 23.097, "s": 0.1144 }, "275": { "l": -1.266, "m": 23.127, "s": 0.1144 }, "276": { "l": -1.263, "m": 23.154, "s": 0.1143 } }