Statistics/Normal distribution: Difference between revisions

m
→‎{{header|R}}: first part was not done
(Add Factor)
m (→‎{{header|R}}: first part was not done)
Line 2,381:
 
=={{header|R}}==
 
R can generate random normal distributed numbers using the [https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Normal.html rnorm] command:
Generate normal random numbers from uniform random numbers, using the [https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform Box-Muller transform]. Both x and y are normally distributed, and independent.
<lang r>n <- 100000
u <- sqrt(-2*log(runif(n)))
v <- 2*pi*runif(n)
x <- u*cos(v)
y <- v*sin(v)
hist(x)</lang>
 
 
R can generate random normal distributed numbers using the [https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Normal.html rnorm] commandfunction:
<lang r>n <- 100000
x <- rnorm(n, mean=0, sd=1)
1,336

edits