| logistic | R Documentation |
Computes the logistic (i.e., sigmoid) function with configurable slope, midpoint, and upper asymptote.
logistic(x, slope = 1, midpoint = 0, upper = 1)
sigmoid(x, slope = 1, midpoint = 0, upper = 1)
x |
Value at which to evaluate the function |
slope |
Slope of logistic function at the midpoint. Defaults to 1. |
midpoint |
Midpoint of logistic function where the output is |
upper |
Upper asymptote (maximal value) of the logistic function. Defaults to 1. |
The logistic function is a smooth S-shaped curve bounded between 0 and upper.
It transitions from near 0 to near upper around the midpoint, with the steepness
of this transition controlled by slope.
Numeric value given by
f(x) = \frac{upper}{1 + e^{-slope \cdot (x - midpoint)}}
logistic(0)
# equivalent:
sigmoid(0)
logistic(1, slope = 5, midpoint = 0.5, upper = 10)
# Visualize different slopes
x <- seq(-5, 5, length.out = 1000)
plot(x, logistic(x, slope = 1), type = "l", ylab = "f(x)", ylim = c(0, 1))
lines(x, logistic(x, slope = 5), col = "blue")
lines(x, logistic(x, slope = 50), col = "red")
legend("topleft", legend = c("slope = 1", "slope = 5", "slope = 50"),
col = c("black", "blue", "red"), lty = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.