Learn R Programming

pi0 (version 1.4-1)

reflect and fold: Reflection and folding of a function about zero

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

reflect(f, ...)
fold(f, ...)

Arguments

f

the function to be reflected or folded

other arguments passed to f

Value

the new function

Details

See examples.

Examples

Run this code
# NOT RUN {
## 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)

# }

Run the code above in your browser using DataLab