Question

In: Math

Generate 1000 random numbers from ??2, 5? starting with standard normal random numbers in R.

  1. Generate 1000 random numbers from ??2, 5? starting with standard normal random numbers in R.

Solutions

Expert Solution

Suppose, we have two independent random samples from standard normal distribution.

Then,

Using this idea we will first generate a set of 2 standard normal random numbers and another set of 5 standard normal random numbers which are independent from the first set of random numbers.

Then we will square the numbers and add then to get the chi-square distribution with degrees of freedom 2 and 5 respectively. Then finally using the relation of F and Chi-square density we generate the random numbers from F(2,5) distribution. We use for loop and iterate for 1000 times to generate 1000 F(2,5) random numbers.

The R-code is given below:

f_random_number = vector()
for (i in 1:1000){
a = rnorm(2,0,1) # generate 2 standard normal random numbers
b = rnorm(5,0,1) # generate 5 standard normal random numbers
  
chi1 = sum(a^2) # chi1 follows chi-square distribution with 2 degrees of freedom
chi2 = sum(b^2) # chi1 follows chi-square distribution with 5 degrees of freedom
  
f = (chi1/2)/(chi2/5) # f is random number from F(2,5)
f_random_number[i]=f
}


Related Solutions

Generate 1000 random numbers from ??3? starting with standard normal random numbers in R.
Generate 1000 random numbers from ??3? starting with standard normal random numbers in R.
Generate 1000 random numbers from a normal distribution with mean 1 and variance 2 using Box‐Muller...
Generate 1000 random numbers from a normal distribution with mean 1 and variance 2 using Box‐Muller transformation in R.
r programming generate 100 samples of size n= 5 from a normal random variable with u=2,...
r programming generate 100 samples of size n= 5 from a normal random variable with u=2, o= 3 in r
A computer was used to generate ten random numbers from a normal distribution with a set...
A computer was used to generate ten random numbers from a normal distribution with a set of unknown mean and variance: −1.1623, 0.2210, 1.6518, −1.1312, −0.2879, −1.0458, 1.3706, −0.7492, −0.1355, −1.2686. Eight more random normal numbers with the same variance perhaps a different mean were then generated (the mean may or may not actually be different): 0.3472, 2.2437, 1.0712, 2.5906, 0.5163, −1.1743, 0.0473, −0.8338. (a) What do you think the means of the random normal number generators were? What do...
Assume that Z  (6). Generate 1000 random numbers from Z and plot the corresponding histogram.
Assume that Z  (6). Generate 1000 random numbers from Z and plot the corresponding histogram.
Write the R code to generate five independent uniform random numbers and use that to generate...
Write the R code to generate five independent uniform random numbers and use that to generate 5 independent Bernoulli random variables with probability of success p = 0.4. please use RStudio. please do not use lab nor rbern for calculations.
Program in R: Generate 1000 exponential random deviates with the mean equal to ½. Be careful!...
Program in R: Generate 1000 exponential random deviates with the mean equal to ½. Be careful! The exponential is sometimes parameterized directly with the mean, B, using 1/B*exp(-x/B) and sometimes it is parameterized with the rate lambda = 1/B. Know what your software is doing. After generating the data, compute the mean and variance of the data. The mean and variance is all I need to see.
3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees...
3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees of freedom. Make a histogram with the samples showing the relative frequencies. Then overlay a probability density plot over this histogram.
Use R to generate two random numbers n11, n21 from the Binomial distribution: Bin(10, 0.4). Print...
Use R to generate two random numbers n11, n21 from the Binomial distribution: Bin(10, 0.4). Print your results. Please don’t forget to use the command set.seed(101) before the commands gen- erating the random numbers. (b) (2 points) Use the R command ntable < − array(data = c(n11, n21, n1plus-n11, n2plus-n21), dim = c(2,2)) to create a 2 × 2 table using the numbers generated in part (a) above. Print your table. (c) (3 points) Perform the Fisher’s exact test on...
Use R and perform following: Generate 1000 observations from an exponential distribution with mean 10. Generate...
Use R and perform following: Generate 1000 observations from an exponential distribution with mean 10. Generate 1000 observations from a central t-distribution with 8 degree of freedom. Make a qqplot of observations in problem 1 versus quantiles generated from a t-distribution with 8 degree of freedom. Can the t distribution be used to approximate data in part 1?Submit the plot. Repeat above part but submit a qqplot of the observations in 1 versus quantiles from an exponential with mean 1....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT