etomica.data
Class AccumulatorAverageCollapsing

java.lang.Object
  extended by etomica.data.DataProcessor
      extended by etomica.data.DataProcessorForked
          extended by etomica.data.DataAccumulator
              extended by etomica.data.AccumulatorAverage
                  extended by etomica.data.AccumulatorAverageCollapsing
All Implemented Interfaces:
DataPipe, DataPipeForked, IDataSink, IDataSource, IEtomicaDataSource, Serializable

public class AccumulatorAverageCollapsing
extends AccumulatorAverage

AccumulatorAverage that adjusts the block size during the simulation. When a certain number of blocks of data have been collected, the blocks are collapsed such that each new block contains the data from two of the old blocks. This allows the accumulator to yield reasonable estimates of the average and uncertainty during the beginning of the simulation and still produce accurate estimates of the uncertainty for longer simulation runs.

This accumulator can only operate on Data with a single value.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class etomica.data.AccumulatorAverage
AccumulatorAverage.StatType
 
Field Summary
protected  double[] blockSums
           
protected  double correlationSum
           
protected  double currentBlockSum
           
protected  int maxBlocks
           
protected  long nominalBlockSize
           
protected  double totalBlockSum
           
protected  double totalSumBlockSq
           
protected  double totalSumSquare
           
 
Fields inherited from class etomica.data.AccumulatorAverage
average, blockCorrelation, blockCountDown, blockSize, count, dataGroup, error, mostRecent, standardDeviation
 
Fields inherited from class etomica.data.DataAccumulator
active, putCount
 
Fields inherited from class etomica.data.DataProcessor
dataInfo, dataSink, tag, trueDataSink
 
Constructor Summary
AccumulatorAverageCollapsing()
          Default constructor sets block size to Default value, and sets the interval for pushing the output data (pushInterval) to 100.
AccumulatorAverageCollapsing(int maxBlocks)
           
AccumulatorAverageCollapsing(int maxBlocks, int blockSize)
           
 
Method Summary
 void addData(IData data)
          Add the given values to the sums and block sums.
protected  void collapseBlocks()
           
protected  void doBlockSum()
          Performs the block sum after blockSize calls to addData.
 IData getData()
          Returns a DataGroup with Data instances holding the statistics kept by this accumulator (as described in general comments for this class).
 DataPipe getDataCaster(IEtomicaDataInfo incomingDataInfo)
          Checks that incoming Data implements Data, and returns null if this is so.
 int getMaxBlocks()
           
 void reset()
          Resets all sums to zero.
 void setBlockSize(long newBlockSize)
          Sets the size of the block used to group data for error analysis.
 void setMaxBlocks(int newMaxBlocks)
           
 
Methods inherited from class etomica.data.AccumulatorAverage
addDataSink, getBlockCount, getBlockSize, getTag, processDataInfo
 
Methods inherited from class etomica.data.DataAccumulator
getPushInterval, isActive, processData, setActive, setPushInterval, toString
 
Methods inherited from class etomica.data.DataProcessorForked
addDataSink, getDataSink, getDataSinks, removeDataSink, setDataSink, setDataSinks
 
Methods inherited from class etomica.data.DataProcessor
getDataInfo, getTag, insertTransformerIfNeeded, putData, putDataInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface etomica.data.IEtomicaDataSource
getDataInfo, getTag
 
Methods inherited from interface etomica.data.DataPipe
getTag
 
Methods inherited from interface etomica.data.IDataSink
putData, putDataInfo
 

Field Detail

maxBlocks

protected int maxBlocks

blockSums

protected double[] blockSums

currentBlockSum

protected double currentBlockSum

totalSumSquare

protected double totalSumSquare

totalSumBlockSq

protected double totalSumBlockSq

correlationSum

protected double correlationSum

totalBlockSum

protected double totalBlockSum

nominalBlockSize

protected long nominalBlockSize
Constructor Detail

AccumulatorAverageCollapsing

public AccumulatorAverageCollapsing()
Default constructor sets block size to Default value, and sets the interval for pushing the output data (pushInterval) to 100.


AccumulatorAverageCollapsing

public AccumulatorAverageCollapsing(int maxBlocks)

AccumulatorAverageCollapsing

public AccumulatorAverageCollapsing(int maxBlocks,
                                    int blockSize)
Method Detail

setMaxBlocks

public void setMaxBlocks(int newMaxBlocks)

getMaxBlocks

public int getMaxBlocks()

getDataCaster

public DataPipe getDataCaster(IEtomicaDataInfo incomingDataInfo)
Checks that incoming Data implements Data, and returns null if this is so. Otherwise throws a ClassCastException, as there is no data caster to Data.

Parameters:
incomingDataInfo - the DataInfo for the Data that will fed to the sink's putData method

addData

public void addData(IData data)
Add the given values to the sums and block sums. If any of the given data values is NaN, method returns with no effect on accumulation sums.

Specified by:
addData in class DataAccumulator

doBlockSum

protected void doBlockSum()
Performs the block sum after blockSize calls to addData.


collapseBlocks

protected void collapseBlocks()

getData

public IData getData()
Returns a DataGroup with Data instances holding the statistics kept by this accumulator (as described in general comments for this class).

Specified by:
getData in interface IDataSource
Specified by:
getData in class DataAccumulator
Returns:
the data given by this source

reset

public void reset()
Resets all sums to zero. All statistics are cleared.

Overrides:
reset in class AccumulatorAverage

setBlockSize

public void setBlockSize(long newBlockSize)
Sets the size of the block used to group data for error analysis. Resets statistics accumulated so far. Default is 1.

Overrides:
setBlockSize in class AccumulatorAverage
Parameters:
blockSize - new block size.