Learn R Programming

salad (version 1.2)

dnorm: Normal distribution

Description

Density for the normal distribution, accepting objects of class 'dual'

Usage

dnorm(x, mean = 0, sd = 1, log = FALSE)

dnorm.dual(x, mean = 0, sd = 1, log = FALSE)

Value

a dual object.

Arguments

x

vector of values

mean

vector of means

sd

vector of standard deviations

log

logical. If TRUE, log of densities are returned

Details

`dnorm.dual` will make straightfoward a computation (in R), that works both with numeric or dual objects. `dnorm` will call `dnorm.dual` if any of the objects is of class dual, or `stats::dnorm` is all objects are of class numeric. As `stats::dnorm` is in written in C it is factor.

If you care for performance, use `stats::dnorm` directly for non dual numbers, and `dnorm.dual` for dual numbers.

Examples

Run this code
x <- dual(0)
dnx <- dnorm(x)
dnx
d(dnx)

Run the code above in your browser using DataLab