Question

Write the code to generate one sample of size n=1 from a standard normal distribution. If the value is between -1.96 and 1.96Write it as Rstudio code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

RStudio Code:


# We can use the function rnorm(no_of_samle , mean , st) to get value value from normal distribution
# since we need one sample , no_of_sample will be 1 and it is standard normal distribution , so
# mean = 0 , standard deviation = 1
num_of_sample = 1
mean_sample = 0
standard_deviation = 1
value = rnorm(1 , mean = mean_sample , sd = standard_deviation)

# Verifying the condition
if(value <= 1.96 && value >= -1.96){
print(value)
} else{
print("It could be potential outlier")
}

1 2 3 4 5 6 7 # We can use the function rnorm(no_of_samle, mean, st) to get value value from normal distribution # since we n

I have run the output many times to see the result.

OUTPUT:

> source/Desktop/S.R) [1] 0.2861043 > source -/Desktop/s.R) [1] 0.1791172 > source(/Desktop/s.R) [1] -1.10725 > source(-

Add a comment
Know the answer?
Add Answer to:
Write it as Rstudio code Write the code to generate one sample of size n=1 from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the code and result in Rstudio or R 1. Suppose we have a random...

    What is the code and result in Rstudio or R 1. Suppose we have a random sample 1.12, 0.44, -1.49, 0.02, 0.81, -1.34,1.34, 0.51,-0.12, 0.97. (a). Use two methods to find the sample mean (b). Use two methods to find the sample variance. (c). Find the sample standard deviation. 2. We can use function rt(n 100, df 2) to generate a random sample from a t-distribution with two degrees of freedom. The sample size is n 100. (a). Generate a...

  • How to do the following in R: Write a function to generate a random sample of size n from the Gam...

    How to do the following in R: Write a function to generate a random sample of size n from the Gamma(α,1) distribution by the acceptance-rejection method. Generate a random sample of size 1000 from the Gamma(3,1) distribution. (Hint: you may use g(x) ∼ Exp(λ = 1/α) as your proposal distribution, where λ is the rate parameter. Figure out the appropriate constant c).

  • Generate a random sample of 20,000 x values (based on a sample of size 30) from...

    Generate a random sample of 20,000 x values (based on a sample of size 30) from a Normal distribution with a mean of 26 and a standard deviation of 5. Be sure to use 30116 as your seed. Find the approximate mean and standard deviation of the sampling distribution of the sample means (x) based on your simulation. No credit will be awarded for responses that do not include R code and output.

  • Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by...

    Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by 21 and will name it tmp. To do so, draw 21×21 = 441 random observations from the standard normal distribution. Before doing so, set the seed for the random number generator to 37. See help for set.seed(). (2) Change the diagonal elements of tmp to 1s. (3) Calculate condition number of tmp. See help for cond(). (4) Calculate the inverse of tmp. See help...

  • Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by...

    Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by 21 and will name it tmp. To do so, draw 21×21 = 441 random observations from the standard normal distribution. Before doing so, set the seed for the random number generator to 37. See help for set.seed(). (2) Change the diagonal elements of tmp to 1s. (3) Calculate condition number of tmp. See help for cond(). (4) Calculate the inverse of tmp. See help...

  • A random sample of size n = 21, taken from a normal population with a standard...

    A random sample of size n = 21, taken from a normal population with a standard deviation 04 =5, has a mean X4 = 90. A second random sample of size n2 = 37, taken from a different normal population with a standard deviation o2 = 4, has a mean X2 = 39. Find a 94% confidence interval for 11 - H2 Click here to view page 1 of the standard normal distribution table. Click here to view page 2...

  • Let X be the mean of a random sample of size n = 75 from the...

    Let X be the mean of a random sample of size n = 75 from the uniform distribution on the interval (0,4), .e 0, otherwise. Approximate the probability P(1.84 < X 〈 2.16).

  • Let X be the mean of a random sample of size n = 75 from the...

    Let X be the mean of a random sample of size n = 75 from the uniform distribution on the interval (0,4), .e 0, otherwise. Approximate the probability P(1.84 < X 〈 2.16).

  • When is unknown and the sample is of size n 230, there are two methods for...

    When is unknown and the sample is of size n 230, there are two methods for computing confidence intervals for u. (Notice that, When is unknown and the sample is of size n<30, there is only one method for constructing a confidence interval for the mean by using the student's t distribution with d.f. = n - 1.) Method 1: Use the Student's t distribution with d.f. = n - 1. This is the method used in the text. It...

  • Let Xi,, Xn be a random sample of size n from the normal distribution with mean...

    Let Xi,, Xn be a random sample of size n from the normal distribution with mean parameter 0 and variance σ2-3. (a) Justify thatX X, has a normal distribution with mean parameter 0 and variance 3 /n, this is, X~N(0,3/m) (you can do it formally using m.g.f. or use results from normal distribution to justify (b) Find the 0.975 quantile of a standard normal distribution (you can use a table, software or internet to find the quantile). (c) Find the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT