gauss: returns a vector with the gaussian equation aginst the input...

View source: R/gauss.R

gaussR Documentation

returns a vector with the gaussian equation aginst the input vector X

Description

The function takes in a vector "X"" against which it returns a vector with the gaussian with the other parameters "amp", "mu", "sig" and "probability"

Usage

gauss(X, amp, sig, mu)
gauss(X, amp, sig, mu, probability=F)
gauss(X, sig, mu, probability=T)

Arguments

X

The (numeric) vector which contain the x_i values against which you need the gaussian vector

probability

A single boolean value.
Defaults to FALSE.
Used to select between a normalized gaussian( probability = T) or a non-normalized statistical distribution( probability = F)

amp

Amplitude, A, of the gaussian or the value of the gaussian at the mean.
Can only be specified when probability = F.
If specified when probability = T, then function throws an error

sig

Describes the standard deviation, \sigma, of the gaussian

mu

Describes the mean value, \mu, or the center of the gaussian.

Details

The function returns the vector y_i against the inputs x_i as shown below.

y_i = Ae^{-(x_i - \mu)^2/(2\sigma^2)} \quad \text{with} \quad A\sqrt{2\pi} = 1/\sigma \,\,\, \text{normalization for density functions}

Value

The returned value is always a numeric vector.

Author(s)

Chitran Ghosal

References

https://en.wikipedia.org/wiki/Gaussian_function

Examples

X <- seq(-10,10,by=0.5)
y <- gauss(X, sig = 1.5, mu = 3, probability = T)
y1 <- gauss(X, amp=1, sig = 1.5, mu = 3, probability = F)
plot(X,y1, type = 'b')
lines(X,y, type='b', col='red')

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.