#' Normal Density Distribution and Probability Plotter
#'
#' Plots the Density of a normal distribution and shades the area and calculates probability of X being equal to or less than 'a'
#'
#' @param mu Mean of the Normal Distribution
#' @param sigma Standard devation of the Normal Distribution
#' @param a Number X is equal to or less than, X<=a
#'
#' @return A Density Distribution Plot with Area under the code shaded and probability, P(X<=a)
#' @export
#'
#' @examples myncurve(mu=10, sigma=5, a=6)
myncurve = function(mu, sigma, a){
curve(dnorm(x,mean=mu,sd=sigma), xlim = c(mu-3*sigma, mu + 3*sigma))
xcurve = seq(mu-3*sigma-10,a,length = 1000)
ycurve = dnorm(xcurve, mean = mu, sd = sigma)
polygon(c(mu-3*sigma-10,xcurve,a),c(0,ycurve,0),col = "pink")
Area = pnorm(a, mean = mu, sd = sigma)-pnorm(mu-3*sigma-10, mean = mu, sd = sigma)
Area = round(Area,4)
text(x = mu ,y = 0.02, paste0("Area=", Area))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.