dist_normal(mu = 0, sigma = 1)

## Arguments

mu The mean (location parameter) of the distribution, which is also the mean of the distribution. Can be any real number. The standard deviation (scale parameter) of the distribution. Can be any positive number. If you would like a Normal distribution with variance $$\sigma^2$$, be sure to take the square root, as this is a common source of errors.

## Details

The Normal distribution is ubiquitous in statistics, partially because of the central limit theorem, which states that sums of i.i.d. random variables eventually become Normal. Linear transformations of Normal random variables result in new random variables that are also Normal. If you are taking an intro stats course, you'll likely use the Normal distribution for Z-tests and in simple linear regression. Under regularity conditions, maximum likelihood estimators are asymptotically Normal. The Normal distribution is also called the gaussian distribution.

We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.

In the following, let $$X$$ be a Normal random variable with mean mu = $$\mu$$ and standard deviation sigma = $$\sigma$$.

Support: $$R$$, the set of all real numbers

Mean: $$\mu$$

Variance: $$\sigma^2$$

Probability density function (p.d.f):

$$f(x) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-(x - \mu)^2 / 2 \sigma^2}$$

Cumulative distribution function (c.d.f):

The cumulative distribution function has the form

$$F(t) = \int_{-\infty}^t \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-(x - \mu)^2 / 2 \sigma^2} dx$$

but this integral does not have a closed form solution and must be approximated numerically. The c.d.f. of a standard Normal is sometimes called the "error function". The notation $$\Phi(t)$$ also stands for the c.d.f. of a standard Normal evaluated at $$t$$. Z-tables list the value of $$\Phi(t)$$ for various $$t$$.

Moment generating function (m.g.f):

$$E(e^{tX}) = e^{\mu t + \sigma^2 t^2 / 2}$$

## Examples

dist <- dist_normal(mu = 1:5, sigma = 3)

dist
#> <distribution[5]>
#> [1] N(1, 9) N(2, 9) N(3, 9) N(4, 9) N(5, 9)mean(dist)
#> [1] 1 2 3 4 5variance(dist)
#> [1] 9 9 9 9 9skewness(dist)
#> [1] 0 0 0 0 0kurtosis(dist)
#> [1] 0 0 0 0 0
generate(dist, 10)
#> [[1]]
#>  [1] -5.0687554  2.2105140  2.6500466  1.0850714  3.6794951 -0.1296665
#>  [7]  2.8176544  0.9853758 -0.5623891 -0.9170558
#>
#> [[2]]
#>  [1]  0.09231759  2.31976093  5.53074274  3.34217346  8.81886430  2.40817462
#>  [7] -3.99711740  0.73849739  0.86477781  5.66232437
#>
#> [[3]]
#>  [1] -1.623091  2.069070  2.939675 -4.170601  5.669596 -1.448440  4.337251
#>  [8]  7.109328  2.939670  2.672347
#>
#> [[4]]
#>  [1]  4.793985  4.911545  3.449835  5.678949  3.440338  1.563174 -0.921745
#>  [8]  5.523767  9.263011  5.777201
#>
#> [[5]]
#>  [1]  8.050140  5.364862  1.765798  1.569303  3.411069  2.956181  4.392657
#>  [8] 10.053487  1.898680  4.532070
#>
density(dist, 2)
#> [1] 0.12579441 0.13298076 0.12579441 0.10648267 0.08065691density(dist, 2, log = TRUE)
#> [1] -2.073106 -2.017551 -2.073106 -2.239773 -2.517551
cdf(dist, 4)
#> [1] 0.8413447 0.7475075 0.6305587 0.5000000 0.3694413
quantile(dist, 0.7)
#> [1] 2.573202 3.573202 4.573202 5.573202 6.573202