-1

I want to create two different vectors of data which are normal distributions. One which has a a mean value of 0 and variance of 1; one which has a mean value of 0 and variance of 0.25.

Can this be done with rnorm? If not what is the best way to do this in R?

RDJ
  • 4,052
  • 9
  • 36
  • 54

2 Answers2

1

Of course. Type ?rnorm into the console to learn more about it. I'm assuming you want vectors with 100 numbers, but just change n if you want.

vector1 = rnorm(n = 100, mean = 0, sd = sqrt(1))
vector2 = rnorm(n = 100, mean = 0, sd = sqrt(0.25))
CephBirk
  • 6,422
  • 5
  • 56
  • 74
1

yes you can do it with rnorm()

first vector( of 1000 elements) with mean = 0 and variance = 1( std.dev = 1)

a = rnorm(1000, mean = 0, sd = 1)

second vector ( of 1000 elements) with mean = 0 and variance = 0.25( std.dev = 0.5)

b = rnorm(1000, mean = 0, sd = 0.5)