Empirical probability in R with x1 x2 2 x3

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 in Machine Learning by Nandini
• 5,480 points
362 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 Dev
• 6,000 points

Related Questions In Machine Learning

0 votes
1 answer

R - plm regression with time in posix-format

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

answered Apr 4, 2022 in Machine Learning by Nandini
• 5,480 points
393 views
0 votes
1 answer

R: Calculate and interpret odds ratio in logistic regression

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

answered Apr 4, 2022 in Machine Learning by Nandini
• 5,480 points
16,113 views
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

answered Apr 4, 2022 in Machine Learning by Nandini
• 5,480 points
1,423 views
0 votes
1 answer

Calculate the probability in R for sum of two dice rolls

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

answered Apr 4, 2022 in Machine Learning by Nandini
• 5,480 points
1,683 views
0 votes
1 answer

Union probability

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

answered Apr 5, 2022 in Machine Learning by Dev
• 6,000 points
499 views
0 votes
1 answer

Plotting logistic regression in R with the Smarket dataset

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

answered Apr 12, 2022 in Machine Learning by Dev
• 6,000 points
718 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP