Skip to content

Instantly share code, notes, and snippets.

@Pengeszikra
Created December 2, 2020 21:05
Show Gist options
  • Select an option

  • Save Pengeszikra/b4156ab48ac3d21bdee68a7fa670fc23 to your computer and use it in GitHub Desktop.

Select an option

Save Pengeszikra/b4156ab48ac3d21bdee68a7fa670fc23 to your computer and use it in GitHub Desktop.
Binomial
const fact = n => n ? fact(n - 1) * n : 1;
const coefficients = (n,k) => Math.round(fact(n) / (fact(k) * fact(n - k)));
const binomial = (p, n, k) => coefficients(n, k) * (p ** k) * ((1 - p) ** (n - k));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment