Skip to content

Instantly share code, notes, and snippets.

@dayvsonlima
Forked from ghalimi/NORMDIST.js
Last active August 29, 2015 14:17
Show Gist options
  • Save dayvsonlima/d73ec66f725cddae0c7d to your computer and use it in GitHub Desktop.
Save dayvsonlima/d73ec66f725cddae0c7d to your computer and use it in GitHub Desktop.
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function NORMDIST(x, mean, sd, cumulative) {
// Check parameters
if (isNaN(x) || isNaN(mean) || isNaN(sd)) return '#VALUE!';
if (sd <= 0) return '#NUM!';
// Return normal distribution computed by jStat [http://jstat.org]
return (cumulative) ? jStat.normal.cdf(x, mean, sd) : jStat.normal.pdf(x, mean, sd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment