5.6 Reductions
5.6.1 Log sum of exponents
real
log_sum_exp
(vector x)
The natural logarithm of the sum of the exponentials of the elements
in x
real
log_sum_exp
(row_vector x)
The natural logarithm of the sum of the exponentials of the elements
in x
real
log_sum_exp
(matrix x)
The natural logarithm of the sum of the exponentials of the elements
in x
5.6.2 Minimum and maximum
real
min
(vector x)
The minimum value in x, or \(+\infty\) if x is empty
real
min
(row_vector x)
The minimum value in x, or \(+\infty\) if x is empty
real
min
(matrix x)
The minimum value in x, or \(+\infty\) if x is empty
real
max
(vector x)
The maximum value in x, or \(-\infty\) if x is empty
real
max
(row_vector x)
The maximum value in x, or \(-\infty\) if x is empty
real
max
(matrix x)
The maximum value in x, or \(-\infty\) if x is empty
5.6.3 Sums and products
real
sum
(vector x)
The sum of the values in x, or 0 if x is empty
real
sum
(row_vector x)
The sum of the values in x, or 0 if x is empty
real
sum
(matrix x)
The sum of the values in x, or 0 if x is empty
real
prod
(vector x)
The product of the values in x, or 1 if x is empty
real
prod
(row_vector x)
The product of the values in x, or 1 if x is empty
real
prod
(matrix x)
The product of the values in x, or 1 if x is empty
5.6.4 Sample moments
Full definitions are provided for sample moments in section array reductions.
real
mean
(vector x)
The sample mean of the values in x; see section
array reductions for details.
real
mean
(row_vector x)
The sample mean of the values in x; see section
array reductions for details.
real
mean
(matrix x)
The sample mean of the values in x; see section
array reductions for details.
real
variance
(vector x)
The sample variance of the values in x; see section
array reductions for details.
real
variance
(row_vector x)
The sample variance of the values in x; see section
array reductions for details.
real
variance
(matrix x)
The sample variance of the values in x; see section
array reductions for details.
real
sd
(vector x)
The sample standard deviation of the values in x; see section
array reductions for details.
real
sd
(row_vector x)
The sample standard deviation of the values in x; see section
array reductions for details.
real
sd
(matrix x)
The sample standard deviation of the values in x; see section
array reductions for details.
5.6.5 Quantile
Produces sample quantiles corresponding to the given probabilities. The smallest observation corresponds to a probability of 0 and the largest to a probability of 1.
Implements algorithm 7 from Hyndman, R. J. and Fan, Y., Sample quantiles in Statistical Packages (R’s default quantile function).
real
quantile
(data vector x, data real p)
The p-th quantile of x
real[]
quantile
(data vector x, data real p[])
An array containing the quantiles of x given by the array of probabilities p
real
quantile
(data row_vector x, data real p)
The p-th quantile of x
real[]
quantile
(data row_vector x, data real p[])
An array containing the quantiles of x given by the array of probabilities p