I have a question - how to generate 100 times a vector of 3 random numbers (x1, x2, x3) from 1 to 10 so I can find the empirical probability of x1+x2>2*x3? I know how to generate 3 random numbers from 1 to 10 with sample(1:10, 3) but how to do this n times?
Mar 7, 2022 473 views

It's easy to duplicate random draws with replicate (here's an example of ten replications):

```Rep <- replicate(10, sample(1:10, 3))

Rep```
 `5` `7` `6` `6` `1` `4` `10` `7` `8` `10` `7` `10` `4` `10` `6` `8` `2` `1` `2` `8` `8` `2` `5` `2` `3` `9` `1` `4` `1` `9`

Your inequality's empirical probability can be determined as follows:

```set.seed(1222)

Rep <- replicate(100, sample(1:10, 3))

prob1 <- mean(reps[1, ] + reps[2, ] > reps[3, ] * 2)

prob1

0.39```

We can produce all 1,000 potential combinations of x1, x2, and x3 just to be sure, because there are only 1,000 possible possibilities.

```all.prob <- expand.grid(1:10, 1:10, (1:10) * 2)

probs <- mean(all.probs[,1] + all.probs[,2] > all.probs[,3])

probs

0.475

```
• 6,000 points

R: Calculate and interpret odds ratio in logistic regression

A logit, or the log of the ...READ MORE

Calculate Z-Score from Probability Value - R programming

It's named qnorm qnorm(p=0.841344746068543) Output 1 The following family of functions ...READ MORE

Calculate the probability in R for sum of two dice rolls

By converting the outer values to a ...READ MORE

Union probability

You can try this if a, b, ...READ MORE