Gscaler: Difference between revisions
imported>Jeremy (Importing text file) |
imported>Scott No edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
GSCALER Applies group/block scaling to submatrices of a single matrix. | GSCALER Applies group/block scaling to submatrices of a single matrix. | ||
===Synopsis=== | ===Synopsis=== | ||
:gys = gscaler(xin,numblocks,mxs,stdxs) | :gys = gscaler(xin,numblocks,mxs,stdxs) | ||
:xin = gscaler(gys,numblocks,mxs,stdxs,undo) | :xin = gscaler(gys,numblocks,mxs,stdxs,undo) | ||
===Description=== | ===Description=== | ||
Inputs are a matrix (xin) (class "double"), the number of sub-matrices/ blocks (numblocks), an offset vector (mxs), and a scale vector (stdxs). | Inputs are a matrix (xin) (class "double"), the number of sub-matrices/ blocks (numblocks), an offset vector (mxs), and a scale vector (stdxs). | ||
See GSCALE for descriptions of (mxs) and (stdxs). | See GSCALE for descriptions of (mxs) and (stdxs). | ||
Note that size(xin,2)/numblocks must be a whole number. | Note that size(xin,2)/numblocks must be a whole number. | ||
When numblocks = 1, all variables are scaled as a single block. | When numblocks = 1, all variables are scaled as a single block. | ||
When numblocks = 0, each variable is handled on its own and gscaler is equivalent to the SCALE function. | When numblocks = 0, each variable is handled on its own and gscaler is equivalent to the SCALE function. | ||
If the optional input (undo) is included with a value of 1 (one), then the input is assumed to be (gys) and is unscaled and uncentered to give the original (xin) matrix. | If the optional input (undo) is included with a value of 1 (one), then the input is assumed to be (gys) and is unscaled and uncentered to give the original (xin) matrix. | ||
In a standard call, the output is the scaled matrix (gys). When undo is provided, the output is the unscaled original matrix (xin). | In a standard call, the output is the scaled matrix (gys). When undo is provided, the output is the unscaled original matrix (xin). | ||
===Examples=== | ===Examples=== | ||
Scale a matrix a that has two blocks augmented together using GSCALE: | Scale a matrix a that has two blocks augmented together using GSCALE: | ||
>> a = [[1 2 3; 4 5 6; 7 8 9] [11 12 13; 14 15 16; 17 18 19]]; | |||
<pre>>> a = [[1 2 3; 4 5 6; 7 8 9] [11 12 13; 14 15 16; 17 18 19]]; | |||
>> [gxs,mxs,stdxs] = gscale(a,2); | >> [gxs,mxs,stdxs] = gscale(a,2); | ||
>> gxs | >> gxs | ||
gxs = | gxs = | ||
-0.5774 -0.5774 -0.5774 -0.5774 -0.5774 -0.5774 | -0.5774 -0.5774 -0.5774 -0.5774 -0.5774 -0.5774 | ||
0 0 0 0 0 0 | 0 0 0 0 0 0 | ||
0.5774 0.5774 0.5774 0.5774 0.5774 0.5774 | 0.5774 0.5774 0.5774 0.5774 0.5774 0.5774 | ||
>> mxs | >> mxs | ||
mxs = | mxs = | ||
4 5 6 14 15 16 | 4 5 6 14 15 16 | ||
>> stdxs | >> stdxs | ||
stdxs = | stdxs = | ||
3 3 3 3 3 3 | |||
3 3 3 3 3 3</pre> | |||
Now scale a new matrix b that has two blocks augmented together: | Now scale a new matrix b that has two blocks augmented together: | ||
>> b = [[2 3 4; 4 5 6; 6 7 8] [10 11 12; 14 15 16; 18 19 20]] | |||
<pre>>> b = [[2 3 4; 4 5 6; 6 7 8] [10 11 12; 14 15 16; 18 19 20]] | |||
b = | b = | ||
2 3 4 10 11 12 | 2 3 4 10 11 12 | ||
4 5 6 14 15 16 | 4 5 6 14 15 16 | ||
6 7 8 18 19 20 | 6 7 8 18 19 20 | ||
>> gys = gscaler(b,2,mxs,stdxs) | >> gys = gscaler(b,2,mxs,stdxs) | ||
gys = | gys = | ||
-0.3849 -0.3849 -0.3849 -0.7698 -0.7698 -0.7698 | -0.3849 -0.3849 -0.3849 -0.7698 -0.7698 -0.7698 | ||
0 0 0 0 0 0 | 0 0 0 0 0 0 | ||
0.3849 0.3849 0.3849 0.7698 0.7698 0.7698 | 0.3849 0.3849 0.3849 0.7698 0.7698 0.7698 | ||
</pre> | |||
===See Also=== | ===See Also=== | ||
[[auto]], [[gscale]], [[mncn]], [[mpca]], [[scale]], [[unfoldm]] | [[auto]], [[gscale]], [[mncn]], [[mpca]], [[scale]], [[unfoldm]] |
Latest revision as of 14:01, 16 September 2008
Purpose
GSCALER Applies group/block scaling to submatrices of a single matrix.
Synopsis
- gys = gscaler(xin,numblocks,mxs,stdxs)
- xin = gscaler(gys,numblocks,mxs,stdxs,undo)
Description
Inputs are a matrix (xin) (class "double"), the number of sub-matrices/ blocks (numblocks), an offset vector (mxs), and a scale vector (stdxs).
See GSCALE for descriptions of (mxs) and (stdxs).
Note that size(xin,2)/numblocks must be a whole number.
When numblocks = 1, all variables are scaled as a single block.
When numblocks = 0, each variable is handled on its own and gscaler is equivalent to the SCALE function.
If the optional input (undo) is included with a value of 1 (one), then the input is assumed to be (gys) and is unscaled and uncentered to give the original (xin) matrix.
In a standard call, the output is the scaled matrix (gys). When undo is provided, the output is the unscaled original matrix (xin).
Examples
Scale a matrix a that has two blocks augmented together using GSCALE:
>> a = [[1 2 3; 4 5 6; 7 8 9] [11 12 13; 14 15 16; 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
Now scale a new matrix b that has two blocks augmented together:
>> b = [[2 3 4; 4 5 6; 6 7 8] [10 11 12; 14 15 16; 18 19 20]] b = 2 3 4 10 11 12 4 5 6 14 15 16 6 7 8 18 19 20 >> gys = gscaler(b,2,mxs,stdxs) gys = -0.3849 -0.3849 -0.3849 -0.7698 -0.7698 -0.7698 0 0 0 0 0 0 0.3849 0.3849 0.3849 0.7698 0.7698 0.7698