statistics
Class Sample

java.lang.Object
  extended by statistics.Sample
All Implemented Interfaces:
java.io.Serializable

public class Sample
extends java.lang.Object
implements java.io.Serializable

A more sophisticated way of storing a Sample. Includes label and data, provides some utility functions.

Author:
sikoried
See Also:
Serialized Form

Field Summary
 int c
          correct label
 double[] x
          data vector
 int y
          classified label
 
Constructor Summary
Sample(int c, double[] x)
          Generate a new sample with the correct label c
Sample(int c, int dim)
          Generate a new (empty) sample
Sample(Sample s)
           
 
Method Summary
static Sample meanSubstract(java.util.List<Sample> data)
          Subtract the mean value from all samples
static java.util.ArrayList<Sample> reduceToClass(java.util.ArrayList<Sample> data, int id)
          Remove all data from a list which is not of label id
static java.util.ArrayList<Sample> removeClass(java.util.ArrayList<Sample> data, int id)
          Remove samples of a certain class from the data set
 java.lang.String toString()
          Return a String representation
static java.util.ArrayList<Sample> unlabeledArrayListFromArray(double[][] data)
          Create an ArrayList of Samples from a double array; one sample per row
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

c

public int c
correct label


x

public double[] x
data vector


y

public int y
classified label

Constructor Detail

Sample

public Sample(int c,
              double[] x)
Generate a new sample with the correct label c

Parameters:
c - correct label
x - data

Sample

public Sample(int c,
              int dim)
Generate a new (empty) sample

Parameters:
c - correct label
dim - feature dimension

Sample

public Sample(Sample s)
Method Detail

meanSubstract

public static Sample meanSubstract(java.util.List<Sample> data)
Subtract the mean value from all samples

Parameters:
data -
Returns:

reduceToClass

public static java.util.ArrayList<Sample> reduceToClass(java.util.ArrayList<Sample> data,
                                                        int id)
Remove all data from a list which is not of label id

Parameters:
data - data set
id - target class
Returns:

removeClass

public static java.util.ArrayList<Sample> removeClass(java.util.ArrayList<Sample> data,
                                                      int id)
Remove samples of a certain class from the data set

Parameters:
data - data set
id - target class
Returns:

toString

public java.lang.String toString()
Return a String representation

Overrides:
toString in class java.lang.Object

unlabeledArrayListFromArray

public static java.util.ArrayList<Sample> unlabeledArrayListFromArray(double[][] data)
Create an ArrayList of Samples from a double array; one sample per row

Parameters:
data - rows will be samples
Returns:
ArrayList of Samples