Return the length of an object
(any)
A JavaScript object.
number
:
An integer.
// returns 0
length(null)
length(undefined)
// returns 1
length(123)
length("abcd")
length(true)
// returns 2
length([1, 2])
length({x:-999, y:999})
Returns the indices of the true elements in an array
(Array)
An array of booleans.
Array
:
An array of indices.
// returns [0, 2]
which([true, false, true])
Generates an arithmetic sequence of number.
(number)
A number; the starting value.
(number)
A number; the (maximal) ending value.
(number)
A number; increment of the sequence.
(number)
A non-negative integer; the desired output length.
Array
:
An array of numbers.
// returns [1, 2, 3]
seq(1, 3)
// returns [2, 4, 6, 8, 10]
seq(2, 10, 2)
// returns [0, 2.5, 5, 7.5, 10]
seq(0, 10, null, 5)
Replicate elements
any
:
A JavaScript Array
// returns [1,1,1]
rep(1, 3)
// returns [1,2,1,2,1,2]
rep([1,2], 3)
// returns [1,1,2,2,2,2]
rep([1,2], [2,4])
The Binomial distribution (PDF)
The Binomial distribution (CDF)
The Binomial distribution (Quantile)
The Binomial distribution (Sampling)
Return the name of the function arguments.
(function)
A function.
any
:
A character array.
function max(a, b) {
return a > b ? a : b;
}
// returns ['a', 'b']
formalArgs(max)
A "factory" for density functions
The function extends the function by the argument log
.
(function)
A function that performs the density calculation.
A "factory" for cumulative density functions (CDF)
The function extends the function by the arguments lower_tail
and log_p
.
(function)
A function that performs the CDF calculation.
A "factory" for quantile functions (CDF)
The function extends the function by the arguments lower_tail
and log_p
.
The first argument of the function must be the probability at which the quantile is seeked.
(function)
A function that performs the quantile calculation.
The digamma function
any
:
A number or an Array of numbers.
The trigamma function
any
:
A number or an Array of numbers.
Return the range of an object.
Array
:
A 2-element Array containing the minimum and the maximum.
range( 1 ) # [1,1]
range([ 1,2,3 ]) # [1,3]
range([ 1,2,[3,4] ]) # [1,4]
Check if all values are true.
(Array)
The input.
boolean
:
true or false; whether all vallues are true.
all([true, true, false]) # false
Check if any value is true.
(Array)
The input.
boolean
:
true or false; whether there is a true value.
any([true, true, false]) # true
Compute incomplete gamma functions
any
:
A triplet {GIN, GIM, GIP}, where
GIN(A, X) := \int_0^x { t^{a - 1}
exp(-t) } dt
GIM(A, X) := Gamma(A) - GIN(A, X) = \int_x^{\infty} { t^{a - 1}
exp(-t) } dt
GIP(A, X) := GIN(A, X) / Gamma(A)
The union of two sets
any
:
An array of elements.
The intersection of two sets
any
:
An array of elements.
The difference of two sets
any
:
An array of elements.
Equality of two sets
boolean
:
true or false.
Check if an element belongs to a set
(any)
An element, or an array of elements.
(Array)
A set; an array of elements.
any
:
An array of elements.
The symmetric difference of two sets
any
:
An array of elements.
A map function for nested Arrays.
any
:
An Array (or a nested Array).
walk([ 1, [2,3], [4,5] ], x => x + 1) // returns [ 2, [ 3, 4 ], [ 5, 6 ] ]
Return the first element of an object
(any)
A JavaScript object.
any
:
The first element of an object.
Combine values into a vector.
(Note that the function does not check that the elements are of the same type. Users should enforce such constraint by themselves.)
Array
:
A JavaScript Array; the combined "vector".
// returns [1, 2, 3]
c(1, 2, 3)
// returns [1, 2, 3, 4]
c(1, 2, c(3, 4))
// returns ["a", "b", "c"]
c("a", "b", "c")