0 votes
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 344 views

1 answer to this question.

0 votes

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

```
answered Mar 15, 2022 by
• 6,000 points

0 votes
1 answer

R - plm regression with time in posix-format

To use in your model, I believe ...READ MORE

0 votes
1 answer

Lear regression using python error - ValueError: operands could not be broadcast together with shapes (1,3) (1,2)

Hey! Your array shapes seem inconsistent. Try ...READ MORE

0 votes
1 answer

While doing NLP in R, I am getting following error - 'no applicable method for 'meta' applied to an object of class "character"' when I run dtm <- DocumentTermMatrix(corpus) command.

Hi, @Adil, I would suggest you go through ...READ MORE

0 votes
1 answer

error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'

Hi@akhtar, This looks as if you don't load ...READ MORE

0 votes
1 answer

R: Calculate and interpret odds ratio in logistic regression

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

0 votes
1 answer

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

0 votes
1 answer

Calculate the probability in R for sum of two dice rolls

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

0 votes
1 answer

Union probability

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

0 votes
1 answer

Plotting logistic regression in R with the Smarket dataset

The first, third, and fourth methods of ...READ MORE

0 votes
1 answer

How to resolve heteroscedasticity in Multiple Linear Regression in R?

Try to use a different form of ...READ MORE