Skip to content

Functions

Zach Ward edited this page Dec 20, 2019 · 13 revisions

Functions

The following functions are available. Most functions can be applied element-wise to matrices. Check each function for details on accepted arguments. Functions will turn maroon in the formula bar.

Function Name Description Arguments Accepts Matrix
abs Absolute Value abs(x): Returns the absolute value of x Real number Yes
acos Arccosine acos(x): Returns the arccosine of x Real number in [-1,1] Yes
asin Arcsine asin(x): Returns the arcsine of x Real number in [-1,1] Yes
atan Arctangent atan(x): Returns the arctangent of x Real number Yes
bound Bounded Value bound(x,a,b): Bounds x to be in [a,b] x: Real number
a: Lower bound (inclusive), real number
b: Upper bound (inclusive), real number
Yes
cbrt Cube Root cbrt(x): Returns the cube root of x Real number Yes
ceil Ceiling ceil(x): Returns the nearest integer above x Real number Yes
choose Binomial Coefficient choose(n,k): Returns the Binomial Coefficient n: Integer
k: Integer
No
cos Cosine cos(x): Returns the cosine of x Real number Yes
cosh Hyperbolic Cosine cosh(x): Returns the hyperbolic cosine of x Real number Yes
erf Error Function erf(x): Returns the error function evaluated at x Real number Yes
exp Exponential Function exp(x): Returns Euler's number e raised to the power of x Real number Yes
fact Factorial fact(n): Returns n! (the factorial of n) Integer ≥0 No
floor Floor floor(x): Returns the nearest integer below x Real number Yes
gamma Gamma Function gamma(x): Returns the gamma function evaluated at x Real number >0 Yes
hypot Hypotenuse hypot(x,y): Returns sqrt(x^2+y^2) without intermediate overflow or underflow x: Real number
y: Real number
No
if If Function if(<expr>,a,b): Returns a if the expression is true and b if it is false <expr>: Boolean expression to evaluate
a: Object returned if true
b: Object returned if false
Yes
invErf Inverse Error Function invErf(x): Returns the inverse error function evaluated at x Real number in [-1,1] Yes
log Natural Log log(x): Returns the natural logarithm (base e) of x Real number >0 Yes
logb Base-b Log logb(x,b): Returns the base-b logarithm of x x: Real number >0
b: Real number >0
Yes
logGamma Log-Gamma Function logGamma(x): Returns the log-Gamma function evaluated at x Real number >0 Yes
log10 Base-10 Log log10(x): Returns the base-10 logarithm of x Real number >0 Yes
logit Logit Function logit(p): Returns the log odds of probability p p: Probability in [0,1] Yes
logistic Logistic Function logistic(x): Returns the standard logistic transformation: 1/(1+exp(-x)) x: Real number Yes
max Maximum max(a,b): Returns the maximum of a and b a: Real number
b: Real number
No
min Minimum min(a,b): Returns the minimum of a and b a: Real number
b: Real number
No
probRescale Probability Rescale probRescale(p,t1,t2): Rescales a probability p from time interval t1 to a new time interval t2 p: Probability in [0,1]
t1: Original time interval >0
t2: New time interval >0
Yes
probToRate Probability to Rate probToRate(p): Converts a probability p to a rate for a fixed time interval
probToRate(p,t1,t2): Converts a probability p per time interval t1 to a rate per time interval t2
p: Probability in [0,1]
t1: Probability time interval >0 (optional)
t2: Rate time interval >0 (optional)
Yes
rateToProb Rate to Probability rateToProb(r): Converts a rate r to a probability for a fixed time interval
rateToProb(r,t1,t2): Converts a rate r per time interval t1 to a probability per time interval t2
r: Rate ≥0
t1: Rate time interval >0 (optional)
t2: Probability time interval >0 (optional)
Yes
round Round round(x): Rounds x to the nearest integer
round(x,n): Rounds x to n decimal places
x: Real number
n: Number of digits (Integer ≥0) (optional)
Yes
sin Sine sin(x): Returns the sine of x Real number Yes
sinh Hyperbolic Sine sinh(x): Returns the hyperbolic sine of x Real number Yes
sqrt Square Root sqrt(x): Returns the square root of x Real number ≥0 Yes
tan Tangent tan(x): Returns the tangent of x Real number Yes
tanh Hyperbolic Tangent tanh(x): Returns the hyperbolic tangent of x Real number Yes
signum Signum Function signum(x): Returns the sign of x (returns -1 or 1) Real number Yes

The following summary functions are also available.

Function Name Description Arguments Accepts Matrix
mean Mean mean(x_1, x_2, ..., x_n): Returns the mean of all arguments x_1 to x_n: Real numbers Yes
product Product product(x_1, x_2, ..., x_n): Returns the product of all arguments x_1 to x_n: Real numbers Yes
quantile Quantile quantile,(q, x_1, x_2, ..., x_n): Returns the quantile q of all arguments q: Quantile to evaluate. Real number (or row vector of real numbers) in [0,1]
x_1 to x_n: Real numbers
Yes
sd Standard Deviation sd(x_1, x_2, ..., x_n): Returns the standard deviation of all arguments x_1 to x_n: Real numbers Yes
sum Sum sum(x_1, x_2, ..., x_n): Returns the sum of all arguments x_1 to x_n: Real numbers Yes
var Variance var(x_1, x_2, ..., x_n): Returns the variance of all arguments x_1 to x_n: Real numbers Yes