-3

I'm having trouble figuring out how to perform the following:

Generate a plot for a normally distributed random variable X with a mean of 250 and variance of 625 (SD 25).

Generate a random sample (n=15) from a normally distributed variable Z with mean=10 variance = 400. Using this sample estimate the population mean for Z and 95% confidence interval.

Essentially the main part I'm struggling with is generating a random sample/variable. Thanks!

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 1
    Hi Rachel, googling your question title brings me here: https://bookdown.org/ndphillips/YaRrr/generating-random-data.html Can you share your code to show where you got stuck? – markus Mar 11 '21 at 15:00

2 Answers2

0

The rnorm() function draws random samples from a normal distribution.

From the normal distribution page in the R manual:

rnorm(n, mean = 0, sd = 1)
   
   n:    number of observations. If length(n) > 1, the 
           length is taken to be the number required.
   mean: vector of means.
   sd:   vector of standard deviations.

So if you need 15 draws with mean 250 and sd 25, rnorm(15, 250, 25).

[1] 250.0760 251.0984 201.1045 231.8379 213.2640 263.3968 274.8070 225.1520
[9] 260.0468 275.5306 295.3408 241.8458 229.2726 285.6786 232.1860
moon prism power
  • 2,347
  • 2
  • 15
  • 24
許弘叡
  • 41
  • 1
0

The function rnorm(n=15,mean=10,sd=sqrt(400)) will supply you with the wanted numbers...

shghm
  • 239
  • 2
  • 8