The Wayback Machine - https://web.archive.org/web/20240118165805/https://www.geeksforgeeks.org/compute-density-of-the-distribution-function-in-r-programming-dunif-function/
Open In App
Related Articles

Compute Density of the Distribution Function in R Programming – dunif() Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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 <- runif(20)
  
dunif(u) == u
  
print(dunif(u))


Output:

 
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Example 2:




# Output to be present as PNG file
png(file = "dunifGFG.png")
  
# Plot density
curve(dunif(x, min = 2, max = 6), 0, 8, ylim = c(0, 0.5),
      ylab = "f(x)", main = "Uniform Density f(x)")
  
# Saving the file
dev.off()


Output:

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 30 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads