##Approach:

To simulate the uniform distribution, I used the runif() function in R, which generates random values from a continuous uniform distribution over a specified interval [π‘Ž,𝑏] I set up the simulation to generate 1,000 values between 0 and 1:

set.seed(123)  # For reproducibility
n <- 1000
min_val <- 0
max_val <- 1
uniform_data <- runif(n, min = min_val, max = max_val)

Visualize with a histogram

This produced a histogram with an approximately flat (uniform) shape, confirming the uniformity of the simulated values.

hist(uniform_data, main = "Histogram of Uniform Distribution", xlab = "Value", breaks = 20)

#Challenges Encountered:

##Understanding Uniformity in Output: Initially, I expected the histogram to be perfectly flat. However, due to random variation, some bins were slightly taller than others. I realized this is normal in finite simulations and can be improved by increasing the sample size (e.g., from 1,000 to 10,000).

##Reproducibility: To ensure consistent results when rerunning the code or sharing it with others, I used set.seed(). Forgetting this initially caused confusion when results varied slightly each time I ran the code.

the Range:

While it’s easy to simulate from 0 to 1, adjusting the interval (e.g., [10, 30]) required changing both min and max parameters correctly. At first, I mistakenly swapped the values, which led to unexpected results.

#Conclusion:

Simulating a uniform distribution is straightforward with built-in functions like runif(). However, attention must be paid to reproducibility, sample size, and parameter setup. Overall, this exercise reinforced my understanding of how uniformly distributed data behaves and how to visually verify its properties using a histogram.