jsynoptic.builtin
Class RandomSource

java.lang.Object
  extended by simtools.data.ValueProvider
      extended by simtools.data.DataSource
          extended by jsynoptic.builtin.RandomSource
Direct Known Subclasses:
GaussianRandomSource, UniformRandomSource

public abstract class RandomSource
extends DataSource

Base class for the uniform and gaussian random sources


Nested Class Summary
static class RandomSource.OptionPanel
           
 
Field Summary
protected  java.util.Random generator
           
protected  DataInfo info
           
protected  long maxIndex
           
protected  double maxValue
           
protected  double minValue
           
protected  double param1
           
protected  double param2
           
static java.util.ResourceBundle resources
           
protected  java.lang.Long seed
           
protected  double[] values
           
 
Fields inherited from class simtools.data.DataSource
endNotificationListeners, listeners, sortedOrder
 
Fields inherited from class simtools.data.ValueProvider
ByteProvider, DoubleProvider, FloatProvider, IntegerProvider, kind, LongProvider, ObjectProvider, ShortProvider
 
Constructor Summary
RandomSource(java.lang.String name, double param1, double param2)
           
RandomSource(java.lang.String name, double param1, double param2, long nSamples)
           
RandomSource(java.lang.String name, long seed, double param1, double param2)
           
RandomSource(java.lang.String name, long seed, double param1, double param2, long nSamples)
           
 
Method Summary
 long computeLastIndex()
           
 java.lang.Object computeMax()
           
 java.lang.Object computeMin()
          Force the computation if possible.
 long computeStartIndex()
           
protected  void fillValues()
           
 double getDoubleMax()
           
 double getDoubleMin()
           
 double getDoubleValue(long index)
          Optimized accessor for double values.
 DataInfo getInformation()
           
 long getLastIndex()
           
 java.lang.Object getMax()
           
 long getMaxIndex()
           
 java.lang.Object getMin()
          Return values if possibly only, without expensive computations.
 long getStartIndex()
           
 java.lang.Object getValue(long index)
           
protected abstract  double nextRandomValue()
          For subclasses to implement according to their distribution
 
Methods inherited from class simtools.data.DataSource
addEndNotificationListener, addListener, computeSortedOrder, createEmptyDataSource, equals, getAuxiliarySources, getByteMax, getByteMin, getChoiceFormat, getDataSourceInformationClass, getFloatMax, getFloatMin, getIntegerMax, getIntegerMin, getLongMax, getLongMin, getShortMax, getShortMin, getSortedOrder, getSourceDependencies, isAuxiliary, isComparable, isCompound, notifyEndNotificationListeners, notifyListenersForDataReplaced, notifyListenersForDataReplaced, notifyListenersForIndexRangeChange, notifyListenersForInfoChange, notifyListenersForOrderChange, notifyListenersForValueChange, notifyListenersForValueRangeChange, removeEndNotificationListener, removeListener, setSlice, sortedOrder, updateSortedOrder
 
Methods inherited from class simtools.data.ValueProvider
getByteValue, getFloatValue, getIntegerValue, getKind, getLongValue, getObjectValue, getShortValue, valueClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resources

public static java.util.ResourceBundle resources

maxIndex

protected long maxIndex

seed

protected java.lang.Long seed

generator

protected java.util.Random generator

param1

protected double param1

param2

protected double param2

minValue

protected double minValue

maxValue

protected double maxValue

values

protected double[] values

info

protected DataInfo info
Constructor Detail

RandomSource

public RandomSource(java.lang.String name,
                    double param1,
                    double param2)

RandomSource

public RandomSource(java.lang.String name,
                    double param1,
                    double param2,
                    long nSamples)

RandomSource

public RandomSource(java.lang.String name,
                    long seed,
                    double param1,
                    double param2)

RandomSource

public RandomSource(java.lang.String name,
                    long seed,
                    double param1,
                    double param2,
                    long nSamples)
Method Detail

getInformation

public DataInfo getInformation()
Overrides:
getInformation in class DataSource

fillValues

protected void fillValues()

nextRandomValue

protected abstract double nextRandomValue()
For subclasses to implement according to their distribution


getValue

public java.lang.Object getValue(long index)
                          throws DataException
Specified by:
getValue in class ValueProvider
Throws:
DataException

getDoubleValue

public double getDoubleValue(long index)
                      throws DataException
Description copied from class: ValueProvider
Optimized accessor for double values. If the provider can provide doubles directly, then it should override this method. Otherwise, the default implementation will do its best to convert the Object returned by getValue() to a double. This conversion also parses strings, and returns 0 if it failed. An exception is thrown if, and only if, getValue throws it.

Overrides:
getDoubleValue in class ValueProvider
Throws:
DataException

computeLastIndex

public long computeLastIndex()
                      throws UnsupportedOperation
Overrides:
computeLastIndex in class DataSource
Throws:
UnsupportedOperation

computeStartIndex

public long computeStartIndex()
                       throws UnsupportedOperation
Overrides:
computeStartIndex in class DataSource
Throws:
UnsupportedOperation

getLastIndex

public long getLastIndex()
                  throws UnsupportedOperation
Overrides:
getLastIndex in class DataSource
Throws:
UnsupportedOperation

getStartIndex

public long getStartIndex()
                   throws UnsupportedOperation
Overrides:
getStartIndex in class DataSource
Throws:
UnsupportedOperation

computeMax

public java.lang.Object computeMax()
Overrides:
computeMax in class DataSource

computeMin

public java.lang.Object computeMin()
Description copied from class: DataSource
Force the computation if possible. The operation may take some time.

Overrides:
computeMin in class DataSource

getDoubleMax

public double getDoubleMax()
Overrides:
getDoubleMax in class DataSource

getDoubleMin

public double getDoubleMin()
Overrides:
getDoubleMin in class DataSource

getMax

public java.lang.Object getMax()
Overrides:
getMax in class DataSource

getMin

public java.lang.Object getMin()
Description copied from class: DataSource
Return values if possibly only, without expensive computations.

Overrides:
getMin in class DataSource

getMaxIndex

public long getMaxIndex()
Returns:
Returns the maxIndex.