de.jstacs.data
Class Sample.WeightedSampleFactory

java.lang.Object
  extended by de.jstacs.data.Sample.WeightedSampleFactory
Enclosing class:
Sample

public static class Sample.WeightedSampleFactory
extends Object

This class enables you to eliminate sequences that occur more than once in one or more samples. The number of occurrence is given by the weight for a sequence.

Author:
Jens Keilwagen

Nested Class Summary
static class Sample.WeightedSampleFactory.SortOperation
          This enum defines the different types of sort operation that can be performed while creating a Sample.WeightedSampleFactory.
 
Constructor Summary
Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort, Sample... data)
          This constructor creates a Sample.WeightedSampleFactory on the given Sample(s).
Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort, Sample[] data, double[][] weights, int length)
          This constructor creates a Sample.WeightedSampleFactory on the given array of Samples and weights.
Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort, Sample data, double[] weights)
          This constructor creates a Sample.WeightedSampleFactory on the given Sample and weights.
Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort, Sample data, double[] weights, int length)
          This constructor creates a Sample.WeightedSampleFactory on the given Sample and weights.
 
Method Summary
 Sequence getElementAt(int index)
          Returns the sequence with index index.
 int getNumberOfElements()
          Returns the number of elements in the internal Sample.
 Sample getSample()
          Returns the sample, where each sequence occurs only once
 double getSumOfWeights()
          Returns the sum of all weights
 double getWeight(int index)
          Returns the weight for the sequence with index index.
 double[] getWeights()
          Returns a copy of the weights for the sample.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sample.WeightedSampleFactory

public Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort,
                                    Sample... data)
                             throws WrongAlphabetException,
                                    WrongLengthException
This constructor creates a Sample.WeightedSampleFactory on the given Sample(s).

Parameters:
sort - the SortOperation
data - the Sample(s)
Throws:
WrongAlphabetException - if the alphabets of the samples do not match
WrongLengthException - does not happen

Sample.WeightedSampleFactory

public Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort,
                                    Sample data,
                                    double[] weights)
                             throws WrongAlphabetException,
                                    WrongLengthException
This constructor creates a Sample.WeightedSampleFactory on the given Sample and weights.

Parameters:
sort - the SortOperation
data - the Sample
weights - the weights for each element in the Sample
Throws:
WrongAlphabetException - if the alphabets of the samples do not match
WrongLengthException - does not happen

Sample.WeightedSampleFactory

public Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort,
                                    Sample data,
                                    double[] weights,
                                    int length)
                             throws WrongAlphabetException,
                                    WrongLengthException
This constructor creates a Sample.WeightedSampleFactory on the given Sample and weights.

Parameters:
sort - the SortOperation
data - the Sample
weights - the weight for each element in the Sample
length - the length of the elements in the resulting WeightedSampleFactory
Throws:
WrongAlphabetException - if the alphabets of the samples do not match
WrongLengthException - if the length is not supported

Sample.WeightedSampleFactory

public Sample.WeightedSampleFactory(Sample.WeightedSampleFactory.SortOperation sort,
                                    Sample[] data,
                                    double[][] weights,
                                    int length)
                             throws WrongAlphabetException,
                                    WrongLengthException
This constructor creates a Sample.WeightedSampleFactory on the given array of Samples and weights.

Parameters:
sort - the SortOperation
data - the Samples
weights - the weights for each element in each Sample
length - the length of the elements in the resulting WeightedSampleFactory
Throws:
WrongAlphabetException - if the alphabets of the samples do not match
WrongLengthException - if the length is not supported
Method Detail

getElementAt

public Sequence getElementAt(int index)
Returns the sequence with index index.

Parameters:
index - the index of the sequence
Returns:
the sequence with index index

getNumberOfElements

public int getNumberOfElements()
Returns the number of elements in the internal Sample.

Returns:
the number of elements in the internal Sample

getSample

public Sample getSample()
Returns the sample, where each sequence occurs only once

Returns:
the sample, where each sequence occurs only once

getSumOfWeights

public double getSumOfWeights()
Returns the sum of all weights

Returns:
the sum of all weights

getWeight

public double getWeight(int index)
Returns the weight for the sequence with index index.

Parameters:
index - the index of the sequence
Returns:
the weight for the sequence with index index

getWeights

public double[] getWeights()
Returns a copy of the weights for the sample.

Returns:
the weights for the sample
See Also:
getSample()

toString

public String toString()
Overrides:
toString in class Object