Distributions in R
R's r/d/p/q family for every common distribution.
set.seed(42)
normals <- rnorm(100, mean = 10, sd = 2)
uniforms <- runif(50, min = 0, max = 1)
coins <- rbinom(20, size = 1, prob = 0.5)
counts <- rpois(30, lambda = 3)
density_at <- dnorm(10, mean = 10, sd = 2)
below <- pnorm(12, mean = 10, sd = 2)
cutoff <- qnorm(0.95, mean = 10, sd = 2)
How it works
rnorm,runif,rbinom,rpoisdraw random samples.dnormgives density;pnormcumulative probability.qnorminverts it, returning the quantile.
Keywords and builtins used here
dnormpnormqnormrbinomrnormrpoisrunif
The run, in numbers
- Lines
- 10
- Characters to type
- 291
- Tokens
- 98
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 65 seconds.
Step 2 of 3 in Describing, step 2 of 11 in Statistics.