Skip to content

Instantly share code, notes, and snippets.

@attiss
Last active December 13, 2022 20:05
Show Gist options
  • Save attiss/57549ac143e59e05ded850960d690c79 to your computer and use it in GitHub Desktop.
Save attiss/57549ac143e59e05ded850960d690c79 to your computer and use it in GitHub Desktop.
Wilks Coefficient for Google Sheets

Wilks coefficient function for Google Sheets

About the Wilks coefficient

The Wilks coefficient or Wilks formula is a mathematical coefficient that can be used to measure the relative strengths of powerlifters despite the different weight classes of the lifters.

(source)

Adding custom functions to Google Sheets

https://developers.google.com/apps-script/guides/sheets/functions

Usage

=WILKS_COEFFICIENT("F";51)*47,5

⬇️

60,11
/**
* Calculates the Wilks Coefficient based on gender and body weight. (https://en.wikipedia.org/wiki/Wilks_coefficient)
*
* @param {string} g Gender ('M' for male, 'F' for female)
* @param {number} x Body weight (in kilkograms)
* @return The calculated Wilks Coefficient.
* @customfunction
*/
function WILKS_COEFFICIENT(g, x) {
let a, b, c, d, e, f;
switch(g) {
case "F":
a = -216.0475144;
b = 16.2606339;
c = -0.002388645;
d = -0.00113732;
e = 7.01863*Math.pow(10,-06);
f = -1.291*Math.pow(10,-08);
break;
case "N":
a = 594.31747775582;
b = -27.23842536447;
c = 0.82112226871;
d = -0.00930733913;
e = 4.731582*Math.pow(10,-05);
f = -9.054*Math.pow(10,-08);
break;
default:
return -1;
}
return 500.0 / (a + b*x + c*Math.pow(x,2) + d*Math.pow(x,3) + e*Math.pow(x,4) + f*Math.pow(x,5));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment