Click or drag to resize

StatMin Method (DoubleMatrix, DataOperation)

Returns the smallest entries in rows or columns of the specified data.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static IndexValuePair[] Min(
	DoubleMatrix data,
	DataOperation dataOperation
)

Parameters

data
Type: Novacta.AnalyticsDoubleMatrix
The data to search for minima.
dataOperation
Type: Novacta.AnalyticsDataOperation
A constant to specify if row or column minima are to be computed.

Return Value

Type: IndexValuePair
The pairs given by the minimum values and their first indexes.
Exceptions
ExceptionCondition
ArgumentNullExceptiondata is null.
ArgumentExceptiondataOperation is not a field of DataOperation.
Remarks

Operating on rows

If dataOperation is OnRows, then the method returns an array of IndexValuePair structures, one for each row in data. The i-th array entry exposes the minimum value in the i-th row through property Value, while the corresponding first column position in the row can be inspected by getting property Index.

Operating on columns

If dataOperation is OnColumns, then the method returns an array of IndexValuePair structures, one for each column in data. The j-th array entry exposes the minimum value in the j-th column through property Value, while the corresponding first row position in the column can be inspected by getting property Index.

Examples

In the following example, row and column smallest entries of the specified data are computed.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class MinExample0  
    {
        public void Main()
        {
            // Create a matrix.
            var data = new double[6] {
               -1, -2,
                2,  3,
                3, -4
            };
            var matrix = DoubleMatrix.Dense(3, 2, data, StorageOrder.RowMajor);
            Console.WriteLine("The data matrix:");
            Console.WriteLine(matrix);

            // Return the smallest entries in columns of the specified data. 
            var columnMins = Stat.Min(matrix, DataOperation.OnColumns);

            Console.WriteLine();
            for (int j = 0; j < matrix.NumberOfColumns; j++) {
                Console.WriteLine("Column {0}: minimum is {1} on row {2}",
                    j, columnMins[j].Value, columnMins[j].Index);
            }

            // Min is overloaded to accept data as a read-only matrix:
            // return the smallest entries in rows using a read-only wrapper of 
            // the data matrix.
            ReadOnlyDoubleMatrix readOnlyMatrix = matrix.AsReadOnly();
            var rowMins = Stat.Min(readOnlyMatrix, DataOperation.OnRows);

            Console.WriteLine();
            for (int i = 0; i < readOnlyMatrix.NumberOfRows; i++) {
                Console.WriteLine("Row {0}: minimum is {1} on column {2}",
                    i, rowMins[i].Value, rowMins[i].Index);
            }
        }
    }
}

// Executing method Main() produces the following output:
// 
// The data matrix:
// -1               -2               
// 2                3                
// 3                -4               
// 
// 
// 
// Column 0: minimum is -1 on row 0
// Column 1: minimum is -4 on row 2
// 
// Row 0: minimum is -2 on column 1
// Row 1: minimum is 2 on column 0
// Row 2: minimum is -4 on column 1

See Also