reflection: Reflection and folding of a function about zero

Description Usage Arguments Details Value Author(s) Examples

Description

reflect reflects the function defined on the nonnegative real line about zero to get a function defined on the whole real line, and then divide it by 2. fold folds a function defined on the whole real line at zero to get a function defined only on the non-negative real line.

Usage

1
2
reflect(f, ...)
fold(f, ...)

Arguments

f

the function to be reflected or folded

...

other arguments passed to f

Details

See examples.

Value

the new function

Author(s)

Long Qu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## reflect function is currently defined as
    function(x,...) ifelse(x>0, f(x,...), f(-x,...))/2

## fold function is currently defined as
    function(x,...) ifelse(x>=0, f(x,...)+f(-x,...), 0)

## double exponential pdf
ddexp=reflect(dexp)

## folded normal pdf
dfnorm=fold(dnorm)

pi0 documentation built on July 9, 2017, 9:01 a.m.