Created
January 5, 2019 14:10
-
-
Save DeoluA/55072c8ec06933ba7e6816d820f9a607 to your computer and use it in GitHub Desktop.
JavaScript implementation of the Normal Probability Density Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://interactive.deolua.com/normal-dist | |
/* | |
*@param number x - the value for which the probability value is desired | |
*@param number mean_val - the value of the mean of the distribution | |
*@param number sd_val_sqrd - the value of the SQUARE of the standard deviation of the distribution | |
*/ | |
var pdf_formula = function(x, mean_val, sd_val_sqrd){ | |
var numer = (x - mean_val)**2; | |
var denom = 2*sd_val_sqrd; | |
var expon = numer/denom; | |
var root_val = Math.sqrt(Math.PI * denom); | |
return ( (1/root_val) * Math.exp(-expon)); | |
}; | |
// want to interact with more distribution and density functions in real time? | |
// Go here for more: https://interactive.deolua.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment