BayES BayES

B.9 Statistical functions, summing, rounding & sorting

The following statemens are used to summarize, sum, round or sort the data contained in a matrix or dataset.



Syntax

Arguments and performed function



W = mean(X [, d]);

W is a matrix with entries equal to the sample mean of the entries of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the mean is computed. The default value for d is 1, for which the mean is calculated over rows.



W = var(X [, d]);

W is a matrix with entries equal to the sample variance of the entries of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the mean is computed. The default value for d is 1, for which the variance is calculated over rows.



W = sd(X [, d]);

W is a matrix with entries equal to the sample standard deviation of the entries of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the standard deviation is computed. The default value for d is 1, for which the standard deviation is calculated over rows.



W = min(X [, d]);

W is a matrix with entries equal to the minimum of the entries of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the minimum is computed. The default value for d is 1, for which the minimum is calculated over rows.



W = max(X [, d] );

W is a matrix with entries equal to the maximum of the entries of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the maximum is computed. The default value for d is 1, for which the maximum is calculated over rows.



W = median(X [ ,d]);

W is a matrix with entries equal to the median of the entries of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the median is computed. The default value for d is 1, for which the median is calculated over rows.



W = tabulate(v [ ,m]);

W is a matrix that contains information on the distribution of the values in vector v. W has three columns:

  1. the first column contains the unique values of v, sorted from smallest to largest

  2. the second column lists the number of times each corresponding unique value in the first column appears in v

  3. the third column lists the number of entries in v smaller than or equal to the corresponding value in the first column (cumulative sum of the second column)

m is an optional argument, specifying the maximum number of unique values in v beyond which an error is produced.

  • v must be a vector or a dataset with a single row or column
  • m must a positive integer. The default value for m is 20.



W = cov(X [, d] );

W is the sample covariance matrix of the variables contained in X, with the variables organized across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension according to which the variables in X are organized. The default value for d is 1, in which case each column of X is treated as a variable.



W = corr(X [, d] );

W is the sample correlation matrix of the variables contained in X, with the variables organized across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension according to which the variables in X are organized. The default value for d is 1, in which case each column of X is treated as a variable.



W = ceil(X);

W is a matrix with dimensions equal to those of X and entries obtained by rounding off the entries of X upwards to the nearest integer. The function works element-wise.

  • X must be a matrix or dataset



W = floor(X);

W is a matrix with dimensions equal to those of X and entries obtained by rounding off the entries of X downwards to the nearest integer. The function works element-wise.

  • X must be a matrix or dataset



W = round(X);

W is a matrix with dimensions equal to those of X and entries obtained by rounding off the entries of X to the nearest integer. The function works element-wise.

  • X must be a matrix or dataset



W = sort(X  [, d]);

W is a matrix with dimensions equal to those of X and entries obtained by sorting, in ascending order, the values of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the sorting should be done. The default value for d is 1, for which the entries of each column of X are sorted in ascending order.

see also sortrows and sortd



W = sortrows(X  [, d]);

W is a matrix with dimensions equal to those of X and entries obtained by sorting the rows of X, in ascending order, according to the values contained in the columns, the indices of which are provided in vector d.

  • X must be a matrix or dataset
  • d must be vector of integers with maximum value not greater than the number of columns of X. The default value for d is 1, for which the rows of of X are sorted in ascending order according to the values contained in the first column. If d contains more than one index, then the rows of X are sorted first according to the first index, and in case of duplicate values in the respective column, according to second index, and so on.

see also sort and sortd



W = sum(X  [, d]);

W is a matrix with entries equal to the sum of the entries of X across dimension d.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the sum is computed. The default value for d is 1, for which the sum is calculated over rows.



W = logsumexp(X  [, d]);

W is a matrix with entries equal to the logarithm of the sum of the exponential of the entries of X across dimension d:
Wj = log i exp Xij
when d is one (or not provided).
The function is provided to guard against overflow when calculating quantities of this form, which appear frequently in the calculation of log-marginal likelihoods.

  • X must be a matrix or dataset
  • d must be either 1 or 2, indicating the dimension across which the sum is computed. The default value for d is 1, for which the sum is calculated over rows.


Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis