heaviside: Heaviside function (step function)

Description Usage Arguments Value Examples

View source: R/various.R

Description

Heaviside function (step function)

Usage

1
heaviside(x, x0 = 0)

Arguments

x

A vector of real numbers.

x0

A real number. The x value at which the function step occurs.

Value

One of the two numbers 0 or 1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- seq(-3,5,length=1000)
x0 <- 1
y <- heaviside(x,x0)
plot(x,y,type="l")
# Step up and step down
x1 <- seq(-3,5,length=1000)
x10 <- 1
y1 <- heaviside(x1,x10)
x2 <- seq(1,9,length=1000)
x20 <- 5
y2 <- heaviside(x2,x20)
y2 <- 1-y2
plot(x1,y1,type="l",xlim=c(-3,9),xlab="x",ylab="y")
points(x2,y2,type="l")

Example output



crone documentation built on Aug. 24, 2019, 5:03 p.m.