# Probability Distributions in R (Examples) | PDF, CDF & Quantile Function

This page explains the functions for different probability distributions provided by the R programming language.

In general, R provides programming commands for the probability distribution function (PDF), the cumulative distribution function (CDF), the quantile function, and the simulation of random numbers according to the probability distributions.

The naming of the different R commands follows a clear structure. See the table below for the names of all R functions:

**Table 1: The Probability Distribution Functions in R.**

Table 1 shows the clear structure of the distribution functions. The names of the functions always contain a d, p, q, or r in front, followed by the name of the probability distribution.

Hereby, d stands for the PDF, p stands for the CDF, q stands for the quantile functions, and r stands for the random numbers generation.

For instance, the normal distribution its PDF is obtained by dnorm, the CDF is obtained by pnorm , the quantile function is obtained by qnorm, and random number are obtained by rnorm.

Below, you can find tutorials on all the different probability distributions. Each tutorial contains reproducible R codes and many examples.

## All Tutorials on Probability Distributions in R

## 4 Comments. Leave new

Hi, I am interested in learning how to R is being used in probability model. In most of the case I could see rolling a fair dice but incase of un-fair dice, how can it be approached. Please share me some resources for probability models using R.

Hey Gowtham,

This could be simulated with the sample function. Within the sample function, you can specify probabilities for each number.

Regards,

Joachim

Hello, dear Mr. Joachim Schork

I’m working on an article, I’m almost finished, now I need a series of x and y data, I want to see if they follow the generalized Rayleigh distribution (Burr type x) or not…

No matter what I do, I cannot find and run the codes in R

Thank you for your advice.

I want to do something like this

install.packages(“fitdistrplus”)

library(“fitdistrplus”)

install.packages(“VGAM”)

library(“VGAM”)

install.packages(“rmutil”)

library(“rmutil”)

######################

##########################

x=c(26,63,19,66,40,49,8,69,39,82,72,66,25,41,16,18,22,42,36,34,53,54,51,76,64,26,16,44,25,55,49,24,44,42,27,28,2)

y=c(20,18,19,85,40,49,8,71,39,48,72,62,9,3,75,18,14,42,52,34,39,7,28,64,15,48,16,13,14,11,49,24,30,2,47,28,2)

data=c(x=x,y=y)

#################################

##########################################################

hist(data)

#######################

plot(density(data))

descdist(data, boot=10000)

#################################

fnorm = fitdist(data, “norm”)

fgamma = fitdist(data, “gamma”)

flognorm = fitdist(data, “lnorm”)

fexp = fitdist(data, “exp”)

########################################

plot.legend = c(“Normal”, “Gamma”, “LogNormal”, “Exponential”)

dist.list = list(fnorm, fgamma, flognorm, fexp)

denscomp(dist.list,legendtext = plot.legend)

cdfcomp(dist.list, legendtext = plot.legend)

###########################################

gofstat(dist.list , fitnames=plot.legend)

ks.test(data, pexp, fexp$estimate[1], fexp$estimate[2])

ks.test(data, pnorm, fnorm$estimate[1], fnorm$estimate[2])

ks.test(data, plognorm, flognorm$estimate[1], flognorm$estimate[2])

ks.test(data, pgamma, fgamma$estimate[1], fgamma$estimate[2])

Hey Mohammad,

I’m not an expert on the generalized Rayleigh distribution. However, I have just tried to run your code, and it seems to work fine. Could you specify your problem in some more detail?

Regards,

Joachim