R’s distribution functions come in four flavors: “d”, “p”, “q”, and “r” (e.g., “dnorm”, “pnorm”, “qnorm”, and “rnorm”). I regularly get them mixed up, so am writing down here what they do for future reference.

# Density

“d” produces the density curve as a function of a random variable. For example, “dnorm” produces:

x <- seq(-4, 4, 0.001) y <- dnorm(x, mean=0, sd=1) plot(x, y, type="l", col="blue", main="Density: dnorm(mean=0, sd=1)", xlab="X", ylab="Density")

# Cumulative Distribution Function

“p” produces the CDF as a function of a random variable. For example, “pnorm” produces:

y <- pnorm(x, mean=0, sd=1) plot(x, y, type="l", col="blue", main="Cumulative Distribution: pnorm(mean=0, sd=1)", xlab="X", ylab="Probability")

# Quantile Function

“q” produces the quantiles as a function of probabilities. For example, “qnorm” produces:

p <- seq(0, 1, 0.001) y <- qnorm(p, mean=0, sd=1) plot(p, y, type="l", col="blue", main="Quantile Function: qnorm(mean=0, sd=1)", xlab="Probability", ylab="X")

# Random Samples

“r” produces random samples from the given distribution. For example, “rnorm” produces:

r <- rnorm(1000, mean=0, sd=1) hist(r, col="lightblue", xlab="X", main="Histogram of rnorm(1000, mean=0, sd=1)")

Hi my name is Lela Guzman and I just wanted to send you a quick note here instead of calling you. I came to your sorting out R’s distribution functions – badass data science website and noticed you could have a lot more visitors. I have found that the key to running a successful website is making sure the visitors you are getting are interested in your website topic. There is a company that you can get keyword targeted traffic from and they let you try the service for free for 7 days. I managed to get over 300 targeted visitors to day to my site. http://wntdco.mx/vlyb4