Normalizations |
Normalizations allow to center or standardize data collection and to ensure boundaries.
Hereinafter the following convention is used:
X denotes data container, i.e. a vector or an array of doubles.
For matrix, columns corresponds to variables, rows corresponds to observations. Thus, the resulting centered or standardized matrix consists of centered/standardized columns, which are calculated analogically to vector case.
Centered collection is calculated using the following formula:
Standardized collection is calculated using the following formula:
Ensuring boundaries involves replacing values below left boundary/above right boundary with boundary value.
The example of vector normalization:
1using System; 2using FinMath.LinearAlgebra; 3using FinMath.Statistics; 4 5namespace FinMath.Samples 6{ 7 class VectorNormalizationsSample 8 { 9 static void Main() 10 { 11 // Input parameters. 12 const Int32 observationCount = 10; 13 const Double trimmingQuantile = 0.25; 14 15 // Generate input vector. 16 Vector vector = Vector.Random(observationCount); 17 Console.WriteLine("Input vector:"); 18 Console.WriteLine(" " + vector.ToString("0.000")); 19 Console.WriteLine(); 20 21 // Print centered data. 22 Console.WriteLine("Centered:"); 23 Console.WriteLine(" " + vector.GetCentered().ToString("0.000")); 24 25 // Print standardized data. 26 Console.WriteLine("Standardized:"); 27 Console.WriteLine(" " + vector.GetStandardized().ToString("0.000")); 28 29 // Print trimmed data. 30 Double quantile = vector.Quantile(trimmingQuantile); 31 Console.WriteLine($"Trimmed (smallest value will be {quantile:0.000}):"); 32 Console.WriteLine(" " + vector.GetEnsuredLeftBoundary(quantile).ToString("0.000")); 33 } 34 } 35}