DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....

## RescaleMatrix

Declaration: RescaleMatrix (var Arr: TDouble2DArray; LowCol, LowRow, HighCol, HighRow: integer; Mode: TRescaleMode; var Par1, Par2: double): integer;
Performs a scaling operation on the two-dimensional array Arr affecting all array elements in the range given by the parameters LowCol, LowRow, HighCol and HighRow. The type of scaling is controlled by the parameter Mode. The variable parameters Par1 and Par2 contain the required scaling parameters on input and the characteristics of the data before the scaling operation on return:

 Mode Scaling Operation Par1 Par2 sctMeanCenter The values of the array are scaled in such a way that the mean becomes zero. in: ignoredout: mean before scaling in: ignoredout: 0 sctStandardize The values are scaled to a zero mean and a standard deviation of 1.0. This normalisation is also known as "standard normal variate" (SNV). in: ignoredout: mean before scaling in: ignoredout: std.dev before scaling sctConstSum The values are scaled to a constant sum defined by the parameter Par1. in: intended sumout: actual sum before the scaling in: ignoredout: 0 sctConstSquaredSum The values are scaled to a constant sum of squared values. The sum is defined by the parameter Par1. in: intended sumout: actual sum before the scaling in: ignoredout: 0 sctMaxAbs The values are scaled in such a way that the maximum absolute value becomes Par1 in: intended maximumout: actual maximum of the absolute values of the minimum and maximum before the scaling in: ignoredout: 0 sctRange The data values are scaled to cover a range between Par1 and Par2 in: intended lower valueout: actual lowest value before the scaling in: intended upper valueout: actual highest value before the scaling sctSquash The data values are compressed by a sigmoid function ("squashing function") to the interval [-1,+1]. The parameter Par1 specifies the origin of the squashing function, the parameter Par2 defines the slope of the function. in: origin of the squashing functionout: same as in in: slope of the squashing functionout: same as in sctQNormalize The data is scaled to zero median and a difference between the median and the p-percentile of 1.0, with p (in %) given by the parameter Par1. in: probability p (>50 and <100)out: median in: ignoredout: difference d of the quantile and the median before the scaling

The function returns the following error codes:

0 ... everything is OK
-1 ... LowCol or HighCol is out of range
-2 ... LowRow or HighRow is out of range
-3 ... array has zero size
-5 ... variance of the data is zero
-6 ... sum of the data is zero
-7 ... the data values are constant
-8 ... maximum intensity is zero
-9 ... probability of quantile must be greater than 50 and less than 100

 Hint: Setting both range limits (i.e. LowCol and HighCol, or LowRow and HighRow to zero values is a shortcut for processing all the cells of the respective dimension. For example, RescaleArray (Data, 0, 10, 0, 20, sctMeanCentered, Par1, Par2); mean-centers the entire rows from row 10 to row 20, as the column parameters LowCol and HighCol has been set to zero.