Click or drag to resize

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:

DSCenter

Standardized collection is calculated using the following formula:

DSStandard

Ensuring boundaries involves replacing values below left boundary/above right boundary with boundary value.

Methods

Operation

Description

Performance

center

Returning result:

StaticGetCentered(Vector, Boolean)

StaticGetCentered(IEnumerableDouble, Boolean)

StaticGetCentered(IEnumerableNullableDouble, Boolean)

Out of place:

StaticGetCentered(Vector, Vector, Boolean)

StaticGetCentered(IEnumerableNullableDouble, IListDouble, Boolean)

StaticGetCentered(IEnumerableDouble, IListDouble, Boolean)

In place:

StaticCenter(Vector, Boolean)

StaticCenter(IListDouble, Boolean)

standardize

Result Returning:

StaticGetStandardized(Vector, Boolean)

StaticGetStandardized(IEnumerableDouble, Boolean)

StaticGetStandardized(IEnumerableNullableDouble, Boolean)

Out of place:

StaticGetStandardized(Vector, Boolean)

StaticGetStandardized(IEnumerableDouble, IListDouble, Boolean)

StaticGetStandardized(IEnumerableNullableDouble, IListDouble, Boolean)

In place:

StaticStandardize(Vector, Boolean)

StaticStandardize(IListDouble, Boolean)

left boundary

Returning result:

StaticGetEnsuredLeftBoundary(Vector, Double, Boolean)

StaticGetEnsuredLeftBoundary(IEnumerableDouble, Double, Boolean)

StaticGetEnsuredLeftBoundary(IEnumerableNullableDouble, Double, Boolean)

Out of place:

StaticGetEnsuredLeftBoundary(Vector, Double, Vector, Boolean)

StaticGetEnsuredLeftBoundary(IEnumerableDouble, Double, IListDouble, Boolean)

StaticGetEnsuredLeftBoundary(IEnumerableNullableDouble, Double, IListDouble, Boolean)

In place:

StaticEnsureLeftBoundary(Vector, Double, Boolean)

StaticEnsureLeftBoundary(IListDouble, Double, Boolean)

right boundary

Returning result:

StaticGetEnsuredRightBoundary(Vector, Double, Boolean)

StaticGetEnsuredRightBoundary(IEnumerableDouble, Double, Boolean)

StaticGetEnsuredRightBoundary(IEnumerableNullableDouble, Double, Boolean)

Out of place:

StaticGetEnsuredRightBoundary(Vector, Double, Vector, Boolean)

StaticGetEnsuredRightBoundary(IEnumerableDouble, Double, IListDouble, Boolean)

StaticGetEnsuredRightBoundary(IEnumerableNullableDouble, Double, IListDouble, Boolean)

In place:

StaticEnsureRightBoundary(Vector, Double, Boolean)

StaticEnsureRightBoundary(IListDouble, Double, Boolean)

both boundaries

Returning result:

StaticGetEnsuredBoundaries(Vector, Double, Double, Boolean)

StaticGetEnsuredBoundaries(IEnumerableDouble, Double, Double, Boolean)

StaticGetEnsuredBoundaries(IEnumerableNullableDouble, Double, Double, Boolean)

Out of place:

StaticGetEnsuredBoundaries(Vector, Double, Double, Vector, Boolean)

StaticGetEnsuredBoundaries(IEnumerableDouble, Double, Double, IListDouble, Boolean)

StaticGetEnsuredBoundaries(IEnumerableNullableDouble, Double, Double, IListDouble, Boolean)

In place:

StaticEnsureBoundaries(IListDouble, Double, Double, Boolean)

Code Sample

The example of vector normalization:

C#
 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}

See Also