org.expasy.jpl.commons.collection.stat
Class HistogramDataSet.Builder

java.lang.Object
  extended by org.expasy.jpl.commons.collection.stat.HistogramDataSet.Builder
All Implemented Interfaces:
InstanceBuilder<HistogramDataSet>
Enclosing class:
HistogramDataSet

public static class HistogramDataSet.Builder
extends Object
implements InstanceBuilder<HistogramDataSet>

Build a binned peak list with binNumber bins, the bins precision is deduced.

Author:
nikitin

Constructor Summary
HistogramDataSet.Builder()
           
HistogramDataSet.Builder(double[] bins, Interval interval)
           
 
Method Summary
 HistogramDataSet.Builder addValue(double value)
          Add value.
 HistogramDataSet.Builder addValues(double[] vals)
          Add values.
 HistogramDataSet.Builder addValuesFromDist(org.apache.commons.math.distribution.ContinuousDistribution dist, int n)
          Add values from continuous distribution.
 HistogramDataSet.Builder addValuesFromDist(org.apache.commons.math.distribution.DiscreteDistribution dist, int trials)
          Add values from discrete distribution.
 HistogramDataSet.Builder addWeight(double value)
          Add weight value.
 HistogramDataSet.Builder addWeights(double[] values)
          Add weights.
 HistogramDataSet.Builder binNumber(int binNumber)
          Set the number of bins.
 HistogramDataSet.Builder binWidth(double binWidth)
          Set the width of each bin.
 HistogramDataSet build()
          Build an instance of BinnedPeakListImpl.
static int computeSize(double from, double to, double binWidth)
          Compute the number of bins.
 HistogramDataSet.Builder freeData()
          Delete data.
 HistogramDataSet.Builder interval(Interval interval)
          Set the interval to make bins.
 HistogramDataSet.Builder normalizedSum(double normalizedSum)
          Set the normalized sum value.
 HistogramDataSet.Builder ppm(double ppm)
          Set the ppm value.
 HistogramDataSet.Builder setMaxWeight(double value)
          Update the maximum weight value and normalize others.
 HistogramDataSet.Builder sortValues()
           
 HistogramDataSet.Builder stdError(double error)
          Set the standard error value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistogramDataSet.Builder

public HistogramDataSet.Builder()

HistogramDataSet.Builder

public HistogramDataSet.Builder(double[] bins,
                                Interval interval)
Method Detail

sortValues

public final HistogramDataSet.Builder sortValues()

addValuesFromDist

public final HistogramDataSet.Builder addValuesFromDist(org.apache.commons.math.distribution.DiscreteDistribution dist,
                                                        int trials)
Add values from discrete distribution.

Parameters:
dist - the discrete distribution.
trialsNumber - the number of trials.
Returns:
this builder.

addValuesFromDist

public final HistogramDataSet.Builder addValuesFromDist(org.apache.commons.math.distribution.ContinuousDistribution dist,
                                                        int n)
Add values from continuous distribution.

Parameters:
dist - the distribution.
n - the number of values from the distribution to generate.
Returns:

addValue

public final HistogramDataSet.Builder addValue(double value)
Add value.

Parameters:
value - the value to add.
Returns:
this builder.

addValues

public final HistogramDataSet.Builder addValues(double[] vals)
Add values.

Parameters:
values - the values to add.
Returns:
this builder.

addWeight

public final HistogramDataSet.Builder addWeight(double value)
Add weight value.

Parameters:
value - the weight value to add.
Returns:
this builder.

addWeights

public final HistogramDataSet.Builder addWeights(double[] values)
Add weights.

Parameters:
values - the weights to add.
Returns:
this builder.

interval

public final HistogramDataSet.Builder interval(Interval interval)
Set the interval to make bins.

Parameters:
interval - the interval limit.
Returns:
this builder.

stdError

public final HistogramDataSet.Builder stdError(double error)
Set the standard error value.

Parameters:
error - the tolerance of the mass spectrometer.
Returns:
this builder.

ppm

public final HistogramDataSet.Builder ppm(double ppm)
Set the ppm value.

Parameters:
ppm - the ppm of the mass spectrometer.
Returns:
this builder.

normalizedSum

public final HistogramDataSet.Builder normalizedSum(double normalizedSum)
Set the normalized sum value.

Parameters:
normalizedSum - the normalized sum.
Returns:
this builder.

setMaxWeight

public final HistogramDataSet.Builder setMaxWeight(double value)
Update the maximum weight value and normalize others.

Parameters:
value - the maximum weight value.
Returns:
this builder.

binWidth

public final HistogramDataSet.Builder binWidth(double binWidth)
Set the width of each bin. warning: cannot set bin number if defined.

Parameters:
binWidth - the bin width.
Returns:
this builder.
See Also:
binNumber

binNumber

public final HistogramDataSet.Builder binNumber(int binNumber)
Set the number of bins. warning: cannot set bin width if defined.

Parameters:
binNumber - the number of bins.
Returns:
this builder.
See Also:
binWidth

freeData

public final HistogramDataSet.Builder freeData()
Delete data.


computeSize

public static int computeSize(double from,
                              double to,
                              double binWidth)
Compute the number of bins.

Parameters:
from - the lowest value.
to - the highest value.
binWidth - the width of bin.
Returns:
the number of bin.

build

public HistogramDataSet build()
                       throws BuilderException
Build an instance of BinnedPeakListImpl.

Specified by:
build in interface InstanceBuilder<HistogramDataSet>
Returns:
an instance of T.
Throws:
BuilderException - - if conditions to build T are not satisfied.


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.