typestar

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

  1. rnorm, runif, rbinom, rpois draw random samples.
  2. dnorm gives density; pnorm cumulative probability.
  3. qnorm inverts it, returning the quantile.

Keywords and builtins used here

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.

Type this snippet

Step 2 of 3 in Describing, step 2 of 11 in Statistics.

← Previous Next →

Distributions in other languages