sigmoid_train: Sigmoid Train

View source: R/sigmoid_train.R

sigmoid_trainR Documentation

Sigmoid Train

Description

Evaluate a train of sigmoid functions at t.

Usage

sigmoid_train(t, ranges, rc)

Arguments

t

Vector (or coerced to a vector) of time values at which the sigmoids are calculated.

ranges

Matrix or array with 2 columns containing the time values within t at which each sigmoid is evaluated. The number of sigmoids is determined by the number of rows in ranges.

rc

Time constant. Either a scalar or a matrix or array with 2 columns containing the rising and falling time constants of each sigmoid. If a matrix or array is passed in rc, its size must equal the size of ranges. If a single scalar is passed in rc, then all sigmoids have the same time constant and are symmetrical.

Details

The number and duration of each sigmoid is determined from ranges. Each row of ranges represents a real interval, e.g. if sigmoid i starts at t = 0.1 and ends at t = 0.5, then ranges[i, ] = c(0.1, 0.5). The input rc is an array that defines the rising and falling time constants of each sigmoid. Its size must equal the size of ranges.

The individual sigmoids are returned in s. The combined sigmoid train is returned in the vector y of length equal to t, and such that y = max(s).

Value

A list consisting two variables; y the combined sigmoid train (length identical to t), and s, the individual sigmoids (number of rows equal to number of rows in ranges and rc.

Author(s)

Juan Pablo Carbajal, carbajal@ifi.uzh.ch.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Examples


t <- seq(0, 2, length.out = 500)
ranges <- rbind(c(0.1, 0.4), c(0.6, 0.8), c(1, 2))
rc <- rbind(c(1e-2, 1e-3), c(1e-3, 2e-2), c(2e-2, 1e-2))
st <- sigmoid_train (t, ranges, rc)
plot(t, st$y[1,], type="n", xlab = "Time(s)", ylab = "S(t)",
     main = "Vectorized use of sigmoid train")
for (i in 1:3) rect(ranges[i, 1], 0, ranges[i, 2], 1,
                    border = NA, col="pink")
for (i in 1:3) lines(t, st$y[i,])
# The colored regions show the limits defined in range.

t <- seq(0, 2, length.out = 500)
ranges <- rbind(c(0.1, 0.4), c(0.6, 0.8), c(1, 2))
rc <- rbind(c(1e-2, 1e-3), c(1e-3, 2e-2), c(2e-2, 1e-2))
amp <- c(4, 2, 3)
st <- sigmoid_train (t, ranges, rc)
y <- amp %*% st$y
plot(t, y[1,], type="l", xlab = 'time', ylab = 'signal',
     main = 'Varying amplitude sigmoid train', col="blue")
lines(t, st$s, col = "orange")
legend("topright", legend = c("Sigmoid train", "Components"),
       lty = 1, col = c("blue", "orange"))


gjmvanboxtel/gsignal documentation built on Nov. 22, 2023, 8:19 p.m.