adplus-dvertising
frame-decoration

Question

Which of the following R code generate a uniform random number?

a.

x <- runif(1, 0, 10)
if(x > 3) {
y <- 10
} else {
y <- 0
}

b.

x <- run(1, 0, 10)
if(x > 3) {
y <- 10
} else {
y <- 0
}

c.

x <- random(1, 0, 10)
if(x > 3) {
y <- 10
} else {
y <- 0
}

d.

x <- random(1, 0, 10)
if(x > 1) {
y <- 0
} else {
x <- 0
}

Answer: (a).x <- runif(1, 0, 10)
if(x > 3) {
y <- 10
} else {
y <- 0
}

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following R code generate a uniform random number?