Gscale: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
No edit summary
imported>Scott
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
:[gxs,mxs,stdxs] = gscale(xin,numblocks)
:[gxs,mxs,stdxs] = gscale(xin,numblocks)


:[gxs,mxs,stdxs] = gscale(xin,numblocks,center)
===Description===
===Description===


GSCALE scales an input matrix xin such that the columns have mean zero, and variance in each block/sub-matrix relative to the total variance in xin equal to one. The purpose is to provide equal sum-of-squares weighting to each block in xin.
GSCALE scales an input matrix xin such that the columns have mean zero, and variance in each block/sub-matrix relative to the total variance in xin equal to one. The purpose is to provide equal sum-of-squares weighting to each block in xin.


Inputs are a matrix xin (class "double") and the number of sub-matrices or blocks numblocks. Note that size(xin,2)/numblocks must be an integer. If numblocks is not included, it is assumed to 1 i.e. the matrix xin is treated as a single block.
Inputs are a matrix xin (class "double" or DataSet Object) and the number of sub-matrices or blocks numblocks.  
numblocks defines how the data should be split into blocks. Three different uses exist:


If (numblocks) is 0 (zero) then automatic mode is used based on the dimensions of the (xin) matrix:
:* '''>0'''  if (numblocks) is > 0, the number of sub-matrices/blocks in the data. Note that size(xin,2)/numblocks must be a whole number. If (numblocks) is not included it is assumed to be 1 (one) and the entire (xin) matrix is treated as a single block.


If (xin) is a three-way array, it is unfolded (combining the first two modes as variables) and the size of the original second mode (size(xin,2)) is used as (numblocks). The output is re-folded back into the original three-way array.
:* '''=0'''  If (numblocks) is 0 (zero) then automatic blocking is done based on the dimensions of the (xin) matrix.
::*If (xin) is a three-way array, it is unfolded (combining the first two modes as variables) and the size of the original second mode (size(xin,2)) is used as (numblocks). The output is re-folded back into the original three-way array. Note that the unfold operation is:  xin = unfoldmw(xin,3);
::*If (xin) is a two-way array, each variable is treated on its own and GSCALE is equivalent to autoscale (see the AUTO function).


Note that the unfold operation is: xin = unfoldmw(xin,3);
:* '''<0'''  If (numblocks) is a negative integer, then class information in the indicated set on mode 2 (the variable mode) is used to divide the blocks. E.g. if numblocks is -3, then the third class set is used to define blocks. This feature is only defined for two-way arrays.


If (xin) is a two-way array, each variable is treated on its own and GSCALE is equivalent to autoscale (see the AUTO function).
center  = A true/false flag indicating whether the xin block should be centered. A value of true or 1 (default) will both center and scale each block. A value of false or 0 will only scale each block without centering it.  


Outputs are the scaled matrix (gxs), a rowvector of means (mxs), and a row vector of "block standard deviations" stdxs.
Outputs are the scaled matrix (gxs), a rowvector of means (mxs), and a row vector of "block standard deviations" stdxs.
NOTE: This function is used with 'Block Variance Scaling' (blockvariance) and 'Group Scale' (gscale) preprocessing methods.


===Examples===
===Examples===
Line 49: Line 55:
===See Also===
===See Also===


[[auto]], [[gscaler]], [[mncn]], [[mpca]], [[scale]], [[unfoldm]]
[[auto]], [[gscaler]], [[mncn]], [[mpca]], [[polytransform]], [[scale]], [[unfoldm]]

Latest revision as of 08:08, 18 July 2017

Purpose

Group/block scaling for a single or multiple blocks.

Synopsis

[gxs,mxs,stdxs] = gscale(xin,numblocks)
[gxs,mxs,stdxs] = gscale(xin,numblocks,center)

Description

GSCALE scales an input matrix xin such that the columns have mean zero, and variance in each block/sub-matrix relative to the total variance in xin equal to one. The purpose is to provide equal sum-of-squares weighting to each block in xin.

Inputs are a matrix xin (class "double" or DataSet Object) and the number of sub-matrices or blocks numblocks. numblocks defines how the data should be split into blocks. Three different uses exist:

  • >0 if (numblocks) is > 0, the number of sub-matrices/blocks in the data. Note that size(xin,2)/numblocks must be a whole number. If (numblocks) is not included it is assumed to be 1 (one) and the entire (xin) matrix is treated as a single block.
  • =0 If (numblocks) is 0 (zero) then automatic blocking is done based on the dimensions of the (xin) matrix.
  • If (xin) is a three-way array, it is unfolded (combining the first two modes as variables) and the size of the original second mode (size(xin,2)) is used as (numblocks). The output is re-folded back into the original three-way array. Note that the unfold operation is: xin = unfoldmw(xin,3);
  • If (xin) is a two-way array, each variable is treated on its own and GSCALE is equivalent to autoscale (see the AUTO function).
  • <0 If (numblocks) is a negative integer, then class information in the indicated set on mode 2 (the variable mode) is used to divide the blocks. E.g. if numblocks is -3, then the third class set is used to define blocks. This feature is only defined for two-way arrays.

center = A true/false flag indicating whether the xin block should be centered. A value of true or 1 (default) will both center and scale each block. A value of false or 0 will only scale each block without centering it.

Outputs are the scaled matrix (gxs), a rowvector of means (mxs), and a row vector of "block standard deviations" stdxs.

NOTE: This function is used with 'Block Variance Scaling' (blockvariance) and 'Group Scale' (gscale) preprocessing methods.

Examples

Scale a matrix a that has two blocks augmented together:

>> a = [[1 2 3; 4 5 6; 7 8 9] [11 12 13; 14 15 16; 17 18 19]]
a =
     1     2     3    11    12    13
     4     5     6    14    15    16
     7     8     9    17    18    19
>> [gxs,mxs,stdxs] = gscale(a,2);
>> gxs
gxs =
   -0.5774   -0.5774   -0.5774   -0.5774   -0.5774   -0.5774
         0         0         0         0         0         0
    0.5774    0.5774    0.5774    0.5774    0.5774    0.5774
>> mxs
mxs =
     4     5     6    14    15    16
>> stdxs
stdxs =
     3     3     3     3     3     3

See Also

auto, gscaler, mncn, mpca, polytransform, scale, unfoldm