Skip to content

Data Science Tutorials

  • Home
  • R
  • Statistics
  • Course
  • Machine Learning
  • Guest Blog
  • Contact
  • About Us
  • Toggle search form
  • How do augmented analytics work
    How do augmented analytics work? R
  • Two Sample Proportions test in R
    Two Sample Proportions test in R-Complete Guide R
  • OLS Regression in R
    OLS Regression in R R
  • Calculate the p-Value from Z-Score in R
    Calculate the p-Value from Z-Score in R R
  • Triangular Distribution in R
    Triangular Distribution in R R
  • 5 Free Books to Learn Statistics For Data Science
    5 Free Books to Learn Statistics For Data Science Course
  • Box Cox transformation in R
    Box Cox transformation in R R
  • Comparing group means in R
    One way ANOVA Example in R-Quick Guide R
The Uniform Distribution in R

The Uniform Distribution in R

Posted on September 18September 18 By Jim 2 Comments on The Uniform Distribution in R
Tweet
Share
Share
Pin

The Uniform Distribution in R, A uniform distribution is a probability distribution where each value in the range from a to b has an equal chance of being selected.

The following formula can be used to determine the likelihood that a value between x1 and x2 will fall within the range from a to b.

Is Data Science a Dying Profession? – Data Science Tutorials

P(obtain value between x1 and x2)  =  (x2 – x1) / (b – a)

Uniform distribution example

The uniform distribution has the following properties:

  • The mean of the distribution is μ = (a + b) / 2
  • The variance of the distribution is σ2 = (b – a)2 / 12
  • The distribution’s standard deviation, or SD, is σ = √σ2

The syntax for uniform distribution in R

We’ll utilize R’s two built-in functions to provide answers using the uniform distribution.

glm function in r-Generalized Linear Models – Data Science Tutorials

They are:

In the formula dunif(x, min, max), where x is the value of a random variable and min and max are the distribution’s minimum and maximum values, respectively, the probability density function (pdf) for the uniform distribution is calculated.

When x is the value of a random variable and min and max are the minimum and maximum values for the distribution, respectively, punif(x, min, max) generates the cumulative distribution function (cdf) for the uniform distribution.

Here you may access the complete R documentation for the uniform distribution.

How to Create an Interaction Plot in R? – Data Science Tutorials

Using the Uniform Distribution to Solve Problems in R

Example 1:

A bus arrives at a bus stop every 8 minutes. What is the chance that the bus will arrive in 5 minutes or less if you arrive at the bus stop?

Solution:

Since we want to know the cumulative probability that the bus will arrive in 5 minutes or less, given that the minimum time is 0 minutes and the maximum time is 8 minutes, we can easily use the punif() function to calculate the probability that the bus will arrive in 5 minutes or less.

punif(5, min=0, max=8)
[1] 0.625

There is a 0.625 percent chance that the bus will arrive within five minutes.

Statistical test assumptions and requirements – Data Science Tutorials

Example 2:

A particular species of frog weighs consistently between 15 and 25 grams. What is the likelihood that a frog you choose at random will weigh between 17 and 19 grams?

Solution:

The cumulative probability of a frog weighing less than 19 pounds will be calculated, and the cumulative likelihood of a frog weighing less than 17 pounds will be subtracted using the syntax shown below.

punif(19, 15, 25) - punif(17, 15, 25)
[1] 0.2

Therefore, there is a 0.2 percent chance that the frog weighs between 17 and 19 grams.

Explanation 3:

An X game lasts between 120 and 170 minutes on average. How likely is it that a randomly chosen X game would go longer than 200 minutes?

Solution:

We may use the formula 1 – to find the answer to this (probability that the game lasts less than 200 minutes).

Top 10 online data science programs – Data Science Tutorials

This comes from

1 - punif(200, 120, 170)

[1] 0

There is a 0 percent chance that a randomly chosen X game will go over 200 minutes.

Check your inbox or spam folder to confirm your subscription.

Tweet
Share
Share
Pin
R

Post navigation

Previous Post: Error in rbind(deparse.level …) numbers of columns of arguments do not match
Next Post: How do augmented analytics work?

Related Posts

  • How to Find Optimal Clusters in R, K-means clustering is one of the most widely used clustering techniques in machine learning.
    How to Find Optimal Clusters in R? R
  • How to Replace String in Column in R
    How to Replace String in Column using R R
  • How to Scale Only Numeric Columns in R
    How to Scale Only Numeric Columns in R R
  • How to Use “not in” operator in Filter
    How to Use “not in” operator in Filter R
  • Checking Missing Values in R
    Checking Missing Values in R R
  • How to Find Unmatched Records in R
    How to Find Unmatched Records in R R

Comments (2) on “The Uniform Distribution in R”

  1. Marc says:
    December 19 at 6:09 pm

    The function returns percentages in decimal form, so 0.625 is 62.5%. You can check this by running punif(.5) which returns 0.5 or 50%.

    Reply
    1. Jim says:
      December 19 at 9:00 pm

      Sure

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • About Us
  • Contact
  • Disclaimer
  • Guest Blog
  • Privacy Policy
  • YouTube
  • Twitter
  • Facebook
  • Tips for Data Scientist Interview Openings
  • What is Epoch in Machine Learning?
  • Dynamic data visualizations in R
  • How Do Machine Learning Chatbots Work
  • Convex optimization role in machine learning

Check your inbox or spam folder to confirm your subscription.

  • Sampling from the population in R
  • Two of the Best Online Data Science Courses for 2023
  • Process of Machine Learning Optimisation?
  • ggplot2 scale in R (grammar for graphics)
  • ggplot aesthetics in R (Grammer of graphics)
  • ggdogs on ggplot2
    ggdogs on ggplot2 R
  • Filter Using Multiple Conditions in R
    Filter Using Multiple Conditions in R R
  • How to Use Spread Function in R
    How to Use Spread Function in R?-tidyr Part1 R
  • Add Significance Level and Stars to Plot in R
    Add Significance Level and Stars to Plot in R R
  • ggpairs in R
    ggpairs in R R
  • How to create a ggalluvial plot in r
    How to create a ggalluvial plot in R? R
  • Arrange the rows in a specific sequence in R
    Arrange the rows in a specific sequence in R R
  • Correlation Coefficient p value in R
    Correlation Coefficient p value in R R

Copyright © 2023 Data Science Tutorials.

Powered by PressBook News WordPress theme