# R Programming Questions and Answers – Simulation – 1

This set of R Programming Language Multiple Choice Questions & Answers (MCQs) focuses on “Simulation – 1”.

1. ________ generate random Normal variates with a given mean and standard deviation.
a) dnorm
b) rnorm
c) pnorm
d) rpois

Explanation: The “r” function is the one that actually simulates random numbers from that distribution.

2. Point out the correct statement?
a) R comes with a set of pseudo-random number generators
b) Random number generators cannot be used to model random inputs
c) Statistical procedure does not require random number generation
d) For each probability distribution there are typically three functions

Explanation: R allows you to simulate from well known probability distributions like the Normal, Poisson, and binomial.

3. ______ evaluate the cumulative distribution function for a Normal distribution.
a) dnorm
b) rnorm
c) pnorm
d) rpois

Explanation: p stands for cumulative distribution.

4. _______ generate random Poisson variates with a given rate.
a) dnorm
b) rnorm
c) pnorm
d) rpois

Explanation: q stands for quantile function (inverse cumulative distribution).

5. Point out the wrong statement?
a) For each probability distribution there are typically three functions
b) For each probability distribution there are typically four functions
c) r function is sufficient for simulating random numbers
d) R comes with a set of pseudo-random number generators

Explanation: There are typically four functions available that start with a “r”, “d”, “p”, and “q”.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Which of the following evaluate the Normal probability density (with a given mean/SD) at a point?
a) dnorm
b) rnorm
c) pnorm
d) rpois

Explanation: That point can be a vector of points.

7. _________ is the most common probability distribution to work with.
a) Gaussian
b) Parametric
d) Simulation

Explanation: Working with the Normal distributions requires using four functions.

8. What will be the output of the following R code?

```> x <- rnorm(10)
> x```

a)

```[1] 0.01874617 -0.18425254 -1.37133055 -0.59916772 0.29454513
[6] 0.38979430 -1.20807618 -0.36367602 -1.62667268 -0.25647839```

b)

```[1] 22.20356 21.51156 19.52353 21.97489 21.48278 20.17869 18.09011
[8] 19.60970 21.85104 20.96596```

c)

```Min. 1st Qu. Median Mean 3rd Qu. Max.
18.09 19.75 21.22 20.74 21.77 22.20```

d) Error

Explanation: Here we simulate standard Normal random numbers with mean 0 and standard deviation 1.

9. What will be the output of the following R code?

```> x <- rnorm(10)
> summary(x)```

a)

```[1] 0.01874617 -0.18425254 -1.37133055 -0.59916772 0.29454513
[6] 0.38979430 -1.20807618 -0.36367602 -1.62667268 -0.25647839```

b)

```[1] 22.20356 21.51156 19.52353 21.97489 21.48278 20.17869 18.09011
[8] 19.60970 21.85104 20.96596```

c)

```Min. 1st Qu. Median Mean 3rd Qu. Max.
18.09 19.75 21.22 20.74 21.77 22.20```

d) Error

Explanation: We can modify the default parameters to simulate numbers with mean 20 and standard deviation 2.

10. What will be the output of the following R code?

` > pnorm(2)`

a) 0.9772499
b) 1.9772499
c) 0.6772499
d) 2.6772499

Explanation: If you wanted to know what was the probability of a random Normal variable of being less than 2, you could use the pnorm() function to do that calculation.

Sanfoundry Global Education & Learning Series – R Programming Language.

Here’s the list of Best Books in R Programming Language.

To practice all areas of R Programming Language, Here is complete set of 1000+ Multiple Choice Questions and Answers.