Calculation - Variance - Variance Each Row

From Q
Jump to navigation Jump to search

This tool is used to compute the variance of the numbers in each row of a table.

Usage

  1. Select the table you wish to use
  2. From the toolbar, select Automate > Browse Online Library > Calculation > Variance > Variance Each Row

Examples

This table shows the average number of orders per month that people placed at a selection of restaurants.

Applying variance results in a new table that contains the variance of the numbers for each row:

Note that by default, the variance calculation will exclude any SUM or NET rows or columns in the table, and you can control which rows or columns to exclude in the options (see below).

Options

The output showing the results of the calculation has the following options available in the Object Inspector.

Input The tables to be used in the calculation.

Calculate for inputs with incomplete data If this option is checked, than any missing values in any of the inputs will be ignored in the calculation. If unchecked, then missing values are not removed before calculation and will propagate as missing values in the output.

Variance formula / Standard Deviation formula This option allows you to choose whether the Population or Sample formula is used to compute the Variance or Standard Deviation (see below).

Automatically match elements Only shown when there are multiple inputs to Input. This controls how and whether matching is done between the labels of the inputs. The default, "Yes - hide unmatched", will look for matching labels in the rows and columns of the inputs before proceeding with the calculation, and any rows/columns that are not contained in all the inputs will not be included in the output. See the Example. For a full description of the matching algorithm, see the Technical Details. "Yes - show unmatched" will also perform matching, but any unmatched rows (columns) will appear in the output as rows (columns) of all missing values. Selecting "No" for this option will cause any labels in the data to be ignored and not perform any matching. Selecting "Custom" will bring up two additional controls that allow for specifying the matching behavior for rows and columns separately.

Match rows Only shown if Automatically match elements is set to "Custom". Specifies the matching behavior when comparing row labels of the inputs. "Yes - show unmatched" and "Yes - hide unmatched" look for exact matches in the row labels in the inputs. "Fuzzy - show unmatched" and "Fuzzy - hide unmatched" perform fuzzy matching so that labels that differ only by a single character are considered to be a match.

Match columns Only shown if Automatically match elements is set to "Custom". The options are the same as Match rows, but control the matching between columns.

Rows to exclude Here you can type in row labels that should be excluded from the calculation.

Columns to exclude As above, but for columns.

Technical Details

The default option is to compute the variance or standard deviation using the sample variance formula rather than the population variance formula. You have the option to choose between these two formulas so that you can apply whichever is relevant to your calculation. If you are a Q user, or are comparing results to those obtained in Q, please note that this default is different to Q's Insert Ready-Made Formulas > Variance and Insert Ready-Made Formulas > Standard Deviation which always use the population formula. In both cases, the standard deviation is the square root of the variance, and the two variance formulas are:

Sample Variance

[math]\displaystyle{ \sigma_{sample}^2=\frac{\sum^n_{i=1}(x_i -\frac{\sum^n_{i=1}x_i }{n})^2}{n-1} }[/math]

Population Variance

[math]\displaystyle{ \sigma_{population}^2=\frac{\sum^n_{i=1}(x_i -\frac{\sum^n_{i=1}x_i }{n})^2}{n} }[/math]

When there are multiple inputs, inputs that contain only a single row (column) may be recycled to a matrix/table with the same number of rows (columns) as the other inputs. For example, if the supplied inputs are a table with three rows and two columns and another table with two rows and a single column, the single column will be expanded by rows into a table with three rows and two columns with each row identical to the original column.

When Automatically match elements is set to Yes - show unmatched or Yes - hide unmatched, both exact matches and fuzzy matches (as described above) are considered, and the order of elements may be permuted so that the names match. It also may transpose an input if, for example, the column names of one input match the row names of another input.

includeWeb('QScript Functions for Calculations');
includeWeb('QScript Functions to Generate Outputs');

applySingleDimensionCalculationWithSelection('Variance', 'Row');

See also