Open In App

Compute Beta Distribution in R Programming – dbeta(), pbeta(), qbeta(), and rbeta() Functions

Last Updated : 19 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Beta Distribution in R Language is defined as property which represents the possible values of probability. This article is an illustration of dbeta, pbeta, qbeta, and rbeta functions of Beta Distribution.

dbeta() Function

It is defined as Beta Density function and is used to create beta density value corresponding to the vector of quantiles.

Syntax: dbeta(vec, shape1, shape2) Parameter: vec: Vector to be used shape1, shape2: beta density of input values Returns: beta density values for a vector of quantiles

Example : 

r




# R program to illustrate the use of
# dbeta() function
 
# Creating a vector
x_beta <- seq(0, 1.5, by = 0.025 ) 
 
# Apply beta function         
y_beta <- dbeta(x_beta, shape1 = 2, shape2 = 4.5) 
 
# Plot beta values
plot(y_beta)                                      


Output:

pbeta() Function

It is used to create cumulative distribution function of the beta distribution.

Syntax: pbeta(vec, shape1, shape2) Parameter: vec: Vector to be used shape1, shape2: beta density of input values

Example: 

r




# Specify x-values for pbeta function
x_pbeta <- seq(0, 1, by = 0.025)     
 
# Apply pbeta() function
y_pbeta <- pbeta(x_pbeta, shape1 = 1, shape2 = 4) 
 
# Plot pbeta values
plot(y_pbeta)


Output:

qbeta() Function

It is known as beta quantile function and used to return quantile values of the function.

Syntax: qbeta(vec, shape1, shape2) Parameters: vec: Vector to be used shape1, shape2: beta density of input values

Example: 

r




# Specify x-values for qbeta() function
x_qbeta <- seq(0, 1, by = 0.025)
 
# Apply qbeta() function
y_qbeta <- qbeta(x_qbeta, shape1 = 1, shape2 = 4) 
 
# Plot qbeta() values
plot(y_qbeta)


Output:

rbeta() Function

It is defined as a random number generator that is used to set seed and specify sample size.

Syntax: rbeta(N, shape1, shape2 ) Parameters: vec: Vector to be used shape1, shape2: beta density of input values

Example: 

r




# Set seed for reproducibility
set.seed(13579)
 
# Specify sample size
N <- 10000 
 
# Draw N beta distributed values
y_rbeta <- rbeta(N, shape1 = 1, shape2 = 5)  
y_rbeta
 
# Plot of randomly drawn beta density
plot(density(y_rbeta),
     main = "beta Distribution in R")


Output:



Similar Reads

Compute the beta value of Non-Negative Numeric Vectors in R Programming - beta() Function
beta() function in R Language is used to return the beta value computed using the beta function. The beta function is also known as Euler's integral of the first kind. Syntax: beta(a, b) Parameters: a, b: non-negative numeric vectors Example 1: # R program to illustrate # beta function # Calling the beta() function beta(1, 2) beta(2, 2) beta(3, 5)
1 min read
Beta Distribution in R
A distribution in statistics is a function that shows the possible values for a variable and how often they occur in the particular experiment or dataset. Beta distribution is one type of probability distribution that represents all the possible outcomes of the dataset. Beta distribution basically shows the probability of probabilities, where α and
6 min read
Compute Density of the Distribution Function in R Programming - dunif() Function
dunif() function in R Language is used to provide the density of the distribution function. Syntax: dunif(x, min = 0, max = 1, log = FALSE) Parameters: x: represents vector min, max: represents lower and upper limits of the distribution log: represents logical value for probabilities Example 1: # Create vector of random deviation u &lt;- runif(20)
1 min read
Compute the Value of Empirical Cumulative Distribution Function in R Programming - ecdf() Function
ecdf() function in R Language is used to compute and plot the value of Empirical Cumulative Distribution Function of a numeric vector. Syntax: ecdf(x) Parameters: x: Numeric Vector Example 1: # R Program to compute the value of # Empirical Cumulative Distribution Function # Creating a Numeric Vector x &lt;- seq(1, 50, by = 2) # Calling ecdf() Funct
1 min read
Compute the value of F Cumulative Distribution Function in R Programming - pf() Function
pf() function in R Language is used to compute the density of F Cumulative Distribution Function over a sequence of numeric values. It also plots a density graph for F Cumulative Distribution. Syntax: pf(x, df1, df2) Parameters: x: Numeric Vector df: Degree of Freedom Example 1: # R Program to compute # Cumulative F Density # Creating a sequence of
1 min read
Compute the value of Quantile Function over F Distribution in R Programming - qf() Function
qf() function in R Language is used to compute the value of quantile function over F distribution for a sequence of numeric values. It also creates a density plot of quantile function over F Distribution. Syntax: qf(x, df1, df2) Parameters: x: Numeric Vector df: Degree of Freedom Example 1: # R Program to compute value of # Quantile Function over F
1 min read
Compute the Value of Quantile Function over Weibull Distribution in R Programming - qweibull() Function
qweibull() function in R Language is used to compute the value of Quantile Function for Weibull Distribution. Syntax: qweibull(x, shape) Parameters: x: Numeric Vector shape: Shape Parameter Example 1: # R Program to compute the value of # Quantile Weibull Function # Creating a sequence of x-values x &lt;- seq(0, 1, by = 0.2) # Calling qweibull() Fu
1 min read
Compute the value of CDF over Studentized Range Distribution in R Programming - ptukey() Function
ptukey() function in R Language is used to compute the value of Cumulative Distribution Function(CDF) over Studentized Range for a sequence of numeric values. Syntax: ptukey(x, nmeans, df) Parameters: x: Numeric Vector nmeans: Number of means df: Degree of Freedom Example 1: # R Program to compute the value of # CDF for Studentized Range # Creating
1 min read
Compute the value of Quantile Function over Studentized Distribution in R Programming - qtukey() Function
qtukey() function in R Language is used to compute the value of Studentized Range Quantile Function over a sequence of Numeric Values. Syntax: qtukey(x, nmeans, df) Parameters: x: Numeric Vector nmeans: Number of means df: Degree of Freedom Example 1: # R Program to compute the value of # Quantile Function Studentized Range # Creating a sequence of
1 min read
Compute the value of PDF over Wilcoxon Signedrank Distribution in R Programming - dsignrank() Function
dsignrank() function in R Language is used to compute the value of Probability Density Function(PDF) over Wilcoxon Signedrank Statistic Distribution for a sequence of Numeric values. Syntax: dsignrank(x, n) Parameters: x: Numeric Vector n: Sample Size Example 1: # R Program to compute the value of # PDF over Wilcoxon Signedrank Distribution # Creat
1 min read