Create Random Deviates of Uniform Distribution in R Programming - runif() Function Last Updated : 07 May, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report runif() function in R Language is used to create random deviates of the uniform distribution.Syntax: runif(n, min, max)Parameters: n: represents number of observations.min, max: represents lower and upper limits of the distribution. Example 1: In this example, we are generating a uniform distribution of 20 random numbers between -1 and 1 using the runif() function in R. The resulting values are evenly distributed across the specified range and are printed for inspection. r x <- runif(20, min = -1, max = 1) print(x) Output: [1] 0.90453974 -0.97083088 0.83531295 0.19008941 0.52278078 -0.75730955 [7] 0.21659920 -0.26621211 0.11967620 0.42081991 0.75518470 -0.41519833[13] -0.03734007 0.57365077 0.76156708 0.97314141 -0.41957919 -0.08910355[19] 0.29047038 -0.67069856Example 2: In this example, we are generating 10,000 random values from a uniform distribution between -5 and 5, and visualizing them with a histogram. We also overlay the theoretical probability density function to illustrate how the generated data aligns with the expected uniform distribution. r unif <- runif(10000, min = -5, max = 5) png(file = "runifGFG.png") hist(unif, freq = FALSE, xlab = 'x', ylim = c(0, 0.4), xlim = c(-6, 6), density = 20, main = "Uniform distribution for the interval [-5, 5]") curve(dunif(x, min = -5, max = 5), from = -10, to = 10, n = 100000, col = "darkgreen", lwd = 2, add = TRUE, yaxt = "n", ylab = 'probability') dev.off() Output: Comment More infoAdvertise with us Next Article Compute the value of CDF on Uniform Distribution in R Programming - punif() Function U utkarsh_kumar Follow Improve Article Tags : R Language R Statistics Similar Reads Create a Random Sequence of Numbers within t-Distribution in R Programming - rt() Function rt() function in R Language is used to create a random sequence of values from Student t-distribution. Syntax: rt(n, df, ncp) Parameters: n: Number of observations df: Degree of Freedom ncp: Numeric vector of non-centrality parameters. Example 1: Python3 1== # R Program to create random sequence # f 1 min read Compute the value of CDF on Uniform Distribution in R Programming - punif() Function In R programming, punif() function is used to compute the value of Cumulative Distribution Function(CDF). Syntax: punif(q, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) Parameters: q: represents vector of quantiles min, max: represents lower and upper limits of the distribution lower.tail: rep 1 min read Compute Randomly Drawn F Density in R Programming - rf() Function rf() function in R Language is used to compute random density for F Distribution. Syntax: rf(N, df1, df2) Parameters: N: Sample Size df: Degree of Freedom Example 1: Python3 1== # R Program to compute random values # of F Density # Setting seed for # random number generation set.seed(1000) # Set sam 1 min read Compute the Value of Quantile Function over Uniform Distribution in R Programming - qunif() Function In R programming, qunif() function gives the value of quantile function over Uniform Distribution. Syntax: qunif(p, min, max, lower.tail = TRUE, log.p = FALSE) Parameters: p: represents probabilities vector min, max: represents lower and upper limits of the distribution lower.tail: represents logica 1 min read Compute Randomly Drawn Poisson Density in R Programming - rpois() Function rpois() function in R Language is used to compute random density for poisson distribution. Syntax: rpois(N, lambda) Parameters: N: Sample Size lambda: Average number of events per interval Example 1: Python3 # R program to compute random # Poisson Density # Setting seed for # random number generatio 1 min read Compute Randomly Drawn Chi Square Density in R Programming - rchisq() Function rchisq() function in R Language is used to compute random chi square density for a set of values. Syntax: rchisq(N, df) Parameters: N: Sample Size df: Degree of Freedom Example 1: Python3 1== # R program to generate # random chi square density points # Setting seed for # random number generation set 1 min read Like