+4 votes
in Programming Languages by (56.5k points)
I want to generate some random probability values (values between 0 and 1) in R. Which R function should I use for it?

1 Answer

+3 votes
by (348k points)
selected by
 
Best answer

R function runif() generates random numbers from a uniform distribution. You can specify 0 as min and 1 as max to get values between 0 and 1.

Here is an example:

> runif(n=10, min = 0, max = 1)
 [1] 0.1209878 0.5843316 0.6590292 0.8450934 0.5096714 0.4319844 0.4592134 0.2865568 0.3900819 0.3433897

Related questions


...