ValueServer
org.apache.commons.math3.random

Class ValueServer



  • public class ValueServerextends Object
    Generates values for use in simulation applications.

    How values are generated is determined by the mode property.

    Supported mode values are:

    • DIGEST_MODE -- uses an empirical distribution
    • REPLAY_MODE -- replays data from valuesFileURL
    • UNIFORM_MODE -- generates uniformly distributed random values with mean = mu
    • EXPONENTIAL_MODE -- generates exponentially distributed random values with mean = mu
    • GAUSSIAN_MODE -- generates Gaussian distributed random values with mean = mu and standard deviation = sigma
    • CONSTANT_MODE -- returns mu every time.

    • Field Detail

      • REPLAY_MODE

        public static final int REPLAY_MODE
        Replay data from valuesFilePath.
        See Also:
        Constant Field Values
      • UNIFORM_MODE

        public static final int UNIFORM_MODE
        Uniform random deviates with mean = μ.
        See Also:
        Constant Field Values
      • EXPONENTIAL_MODE

        public static final int EXPONENTIAL_MODE
        Exponential random deviates with mean = μ.
        See Also:
        Constant Field Values
      • GAUSSIAN_MODE

        public static final int GAUSSIAN_MODE
        Gaussian random deviates with mean = μ, std dev = σ.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ValueServer

        public ValueServer()
        Creates new ValueServer
      • ValueServer

        @Deprecatedpublic ValueServer(RandomDataImpl randomData)
        Construct a ValueServer instance using a RandomDataImpl as its source of random data.
        Parameters:
        randomData - the RandomDataImpl instance used to source random data
      • ValueServer

        public ValueServer(RandomGenerator generator)
        Construct a ValueServer instance using a RandomGenerator as its source of random data.
        Parameters:
        generator - source of random data
    • Method Detail

      • computeDistribution

        public void computeDistribution()                         throws IOException,                                ZeroException,                                NullArgumentException
        Computes the empirical distribution using values from the file in valuesFileURL, using the default number of bins.

        valuesFileURL must exist and be readable by *this at runtime.

        This method must be called before using getNext() with mode = DIGEST_MODE

        Throws:
        IOException - if an I/O error occurs reading the input file
        NullArgumentException - if the valuesFileURL has not been set
        ZeroException - if URL contains no data
      • computeDistribution

        public void computeDistribution(int binCount)                         throws NullArgumentException,                                IOException,                                ZeroException
        Computes the empirical distribution using values from the file in valuesFileURL and binCount bins.

        valuesFileURL must exist and be readable by this process at runtime.

        This method must be called before using getNext() with mode = DIGEST_MODE

        Parameters:
        binCount - the number of bins used in computing the empirical distribution
        Throws:
        NullArgumentException - if the valuesFileURL has not been set
        IOException - if an error occurs reading the input file
        ZeroException - if URL contains no data
      • getMode

        public int getMode()
        Returns the data generation mode. See the class javadoc for description of the valid values of this property.
        Returns:
        Value of property mode.
      • setMode

        public void setMode(int mode)
        Sets the data generation mode.
        Parameters:
        mode - New value of the data generation mode.
      • getValuesFileURL

        public URL getValuesFileURL()
        Returns the URL for the file used to build the empirical distribution when using DIGEST_MODE.
        Returns:
        Values file URL.
      • setValuesFileURL

        public void setValuesFileURL(URL url)
        Sets the the values file URL.

        The values file must be an ASCII text file containing one valid numeric entry per line.

        Parameters:
        url - URL of the values file.
      • resetReplayFile

        public void resetReplayFile()                     throws IOException
        Resets REPLAY_MODE file pointer to the beginning of the valuesFileURL.
        Throws:
        IOException - if an error occurs opening the file
      • closeReplayFile

        public void closeReplayFile()                     throws IOException
        Closes valuesFileURL after use in REPLAY_MODE.
        Throws:
        IOException - if an error occurs closing the file
      • setMu

        public void setMu(double mu)
        Sets the mean used in data generation. Note that calling this method after computeDistribution() has been called will have no effect on data generated in DIGEST_MODE.
        Parameters:
        mu - new Mean value.
      • getSigma

        public double getSigma()
        Returns the standard deviation used when operating in GAUSSIAN_MODE. Calling computeDistribution() sets this value to the overall standard deviation of the values in the values file. This property has no effect when the data generation mode is not GAUSSIAN_MODE.
        Returns:
        Standard deviation used when operating in GAUSSIAN_MODE.
      • reSeed

        public void reSeed(long seed)
        Reseeds the random data generator.
        Parameters:
        seed - Value with which to reseed the RandomDataImpl used to generate random data.

SCaVis 1.7 © jWork.org