Extreme Optimization > User's Guide > Statistics Library > Variable Collections > Key Variables

Extreme Optimization User's Guide

User's Guide

Up: Variable Collections Next: Variable Collections Previous: Variable Collections Contents

Key Variables

Within a data set, there may be one or more variables that can uniquely identify an observation. These variables act as keys into the variable collection, and are therefore called key variables. In the Extreme Optimization Numerical Libraries for .NET, categorical variables are implemented by the KeyVariable class.

Constructing key variables

The KeyVariable class has four constructors that come in two groups.

The first group uses a ICollection as the source of the data. The first variant has two parameters. The first is a string that specifies the name of the variable. The second parameter is an object that implements the ICollection interface. This includes arrays, array lists, hash tables, and more. The second variant only takes one parameter: an object that implements the ICollection interface containing the data values.

C# CopyCode imageCopy Code
string[] dataArray = new string[]
    {"Store 1", "Store 2", "Store 3", "Store 4", "Store 5", "Store 6"};
KeyVariable variable1 = new KeyVariable(dataArray);
KeyVariable variable2 = new KeyVariable("Store", dataArray);
Visual Basic CopyCode imageCopy Code
Dim dataArray As String() = New String() _
    {"Store 1", "Store 2", "Store 3", "Store 4", "Store 5", "Store 6"}
    
Dim variable1 As KeyVariable = New KeyVariable("Store", dataArray)
Dim variable2 As KeyVariable = New KeyVariable(dataArray)

The second pair of constructors uses a DataColumn as the source of the data. The first variant once again has two parameters. The first is a string that specifies the name of the variable. The second parameter is a DataColumn. The name of the variable is set to the Caption property of the data column.

C# CopyCode imageCopy Code
DataColumn column;
// Connect to a data source and retrieve the column from a DataTable
KeyVariable variable3 = new KeyVariable(column);
KeyVariable variable4 = new KeyVariable("Store", column);
Visual Basic CopyCode imageCopy Code
Dim column As DataColumn
' Connect to a data source and retrieve the column from a DataTable
Dim variable3 As KeyVariable = New KeyVariable("Store", column)
Dim variable4 As KeyVariable = New KeyVariable(column)

In addition, variables can be created by VariableCollection objects, by converting numerical and date/time variables (see a later section on conversions), and several other means.

Properties and Methods

The Length property returns the number of observations for the variable.

The GetValue method returns the value (observation) with the specified index. The GetKeys method returns an array of objects containing the key values. A new array instance is returned on every call. The GetEnumerator method returns an IEnumerator object that can be used to iterate through the key values.

Key variables have no descriptive statistics associated with them.

Up: Variable Collections Next: Variable Collections Previous: Variable Collections Contents

Overview
Introduction
Features
Documentation
QuickStart Samples
Sample Applications
Downloads
Get it now!
Download trial version
How to Buy
Information
Resources
Contact Us
Search

"The Extreme Optimization Statistics Library for .NET is a major boon for those doing statistical work in .NET. I strongly recommend this product."
- Marc Brooks

"I have made it my mission to institutionalize the value of good API design.  I strongly believe that this is key to making developers more productive and happy on our platform. It is clear that you value good API design in your work, and take to heart developer productivity and synergy with the .NET framework."
- Brad Abrams,
Lead Program Manager, Microsoft.

This is a partial list of companies who are using our libraries:
ABB Robotics
Allstate
Applied Materials
Arcam
Astra Schedule
Babson College
Canadian Council on Learning
Canyon Associates
Caxton Associates
CECity
Constellation Energy
CreditSights
DeepOcean
Duke University
Dynamotive
Elecsoft
Engelhard Corporation
Epcor
Equipoise Software
Galileo International
GAM UK
Gammex
GlaxoSmithKline
Global Matrix
The Hartford
Infinera Corporation
Intel
JDS Uniphase
LaBranche & Co.
Learning & Skills Council
Jacobs Consultancy
Litman Gregory
Lucas Systems
Malvern Instruments
Medrio
Merck & Co.
Mintera.
Monitor Software
MorningStar
NanoString Technologies
Paletta Invent
Parametric Portfolio Associates
Prosanos
RATA Associates
RiskShield
Ramboll
Standard & Poor's
Strategic Analysis Corporation
Univ. of Alicante
Univ. of South Carolina
vielife
Xerox
US Army