# piecewise_x

0th

Percentile

##### Piecewise real function.

Given the vectors (breaks[1],...,breaks[n]) and the list of IBMPopSim compatible functions funs = (f[0],f[1],...,f[n]) (one value more!), piecewise_x(breaks, funs) returns the function $$f(x) = f_0(x){1}_{x\le breaks[1]}+\sum_{k=1}^{n-1} f_k(x) {1}_{[breaks_{k}, breaks_{k+1})}(x) + f_n(x){1}_{x \ge breaks[n]}$$

##### Usage
piecewise_x(breaks, funs)
##### Arguments
breaks

Numeric vector giving the breaks of functions given in funs. Must be sorted with unique values.

funs

List of functions.

##### Details

A C++ version of this function is available. See vignette('IBMPopSim_cpp') for more details.

##### Value

Piecewise function built with the given intervals and functions.

• piecewise_x
##### Examples
# NOT RUN {
dr <- with(EW_pop_14\$rates,
stepfun(x=death_male[,"age"], y=c(0,death_male[,"value"])))
# before age 80 the stepfun and after age 80 the gompertz function
f <- piecewise_x(80, list(dr, gompertz(0.00006, 0.085)))
x <- seq(40:120)
plot(x, sapply(x, f))

# }

Documentation reproduced from package IBMPopSim, version 0.3.0, License: MIT + file LICENSE

### Community examples

Looks like there are no examples yet.