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

## RescaleVector

Declaration: RescaleVector (var Arr: TDoubleArray; First, Last: integer; Mode: TRescaleMode; var Par1, Par2: double): integer;

Performs a scaling operation on the one-dimensional array Arr affecting all array elements from First to Last. 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 ... array has zero size
-2 ... variance of the data is zero
-3 ... sum of the data is zero
-4 ... data has a zero range
-5 ... maximum value is zero
-6 ... probability of quantile must be greater than 50 and less than 100

 Hint: Setting both First and Last to a zero value is a shortcut for processing the entire array.