Skip to content

Estimates parameters of the Gaussian distribution (\(\mu\), \(\sigma\)) via non-linear least-squares, making Gaussian assumptions of the error function, see pnorm(). Initial starting values are chosen via robust estimates, median() and mad(). If mad = TRUE, these starting values are returned.

Usage

fit_gauss(x, mad = FALSE)

Arguments

x

numeric(n). A vector of numeric values to fit to Gaussian assumptions.

mad

logical(1). Should median() and mad() * 1.4826 be used as robust (i.e. distribution-free) estimates of population mean and standard deviation?

Value

A named vector consisting of non-linear least-squares estimates of mu and sigma for x.

See also

Author

Stu Field

Examples

x <- rnorm(100, 25, 3)
fit_gauss(x)
#>        mu     sigma 
#> 24.368735  3.006532 
fit_gauss(x, mad = TRUE)
#>        mu     sigma 
#> 24.485358  3.072565