public class ValueServer extends Object
How values are generated is determined by the mode
property.
Supported mode
values are:
valuesFileURL
mu
mu
mu
and
standard deviation = sigma
mu
every time.Modifier and Type | Field and Description |
---|---|
static int |
CONSTANT_MODE
Always return mu
|
static int |
DIGEST_MODE
Use empirical distribution.
|
static int |
EXPONENTIAL_MODE
Exponential random deviates with mean = μ.
|
static int |
GAUSSIAN_MODE
Gaussian random deviates with mean = μ, std dev = σ.
|
static int |
REPLAY_MODE
Replay data from valuesFilePath.
|
static int |
UNIFORM_MODE
Uniform random deviates with mean = μ.
|
Constructor and Description |
---|
ValueServer()
Creates new ValueServer
|
ValueServer(RandomDataImpl randomData)
Deprecated.
|
ValueServer(RandomGenerator generator)
Construct a ValueServer instance using a RandomGenerator as its source
of random data.
|
Modifier and Type | Method and Description |
---|---|
void |
closeReplayFile()
Closes
valuesFileURL after use in REPLAY_MODE. |
void |
computeDistribution()
Computes the empirical distribution using values from the file
in
valuesFileURL , using the default number of bins. |
void |
computeDistribution(int binCount)
Computes the empirical distribution using values from the file
in
valuesFileURL and binCount bins. |
void |
fill(double[] values)
Fills the input array with values generated using getNext() repeatedly.
|
double[] |
fill(int length)
Returns an array of length
length with values generated
using getNext() repeatedly. |
EmpiricalDistribution |
getEmpiricalDistribution()
Returns the
EmpiricalDistribution used when operating in 0. |
int |
getMode()
Returns the data generation mode.
|
double |
getMu()
|
double |
getNext()
Returns the next generated value, generated according
to the mode value (see MODE constants).
|
double |
getSigma()
Returns the standard deviation used when operating in
GAUSSIAN_MODE . |
URL |
getValuesFileURL()
Returns the URL for the file used to build the empirical distribution
when using
DIGEST_MODE . |
void |
reSeed(long seed)
Reseeds the random data generator.
|
void |
resetReplayFile()
Resets REPLAY_MODE file pointer to the beginning of the
valuesFileURL . |
void |
setMode(int mode)
Sets the data generation mode.
|
void |
setMu(double mu)
Sets the
mean used in data generation. |
void |
setSigma(double sigma)
Sets the
standard deviation used in GAUSSIAN_MODE . |
void |
setValuesFileURL(String url)
Sets the
values file URL using a string
URL representation. |
void |
setValuesFileURL(URL url)
Sets the the
values file URL . |
public static final int DIGEST_MODE
public static final int REPLAY_MODE
public static final int UNIFORM_MODE
public static final int EXPONENTIAL_MODE
public static final int GAUSSIAN_MODE
public static final int CONSTANT_MODE
public ValueServer()
@Deprecated public ValueServer(RandomDataImpl randomData)
ValueServer(RandomGenerator)
randomData
- the RandomDataImpl instance used to source random datapublic ValueServer(RandomGenerator generator)
generator
- source of random datapublic double getNext() throws IOException, MathIllegalStateException, MathIllegalArgumentException
IOException
- in REPLAY_MODE if a file I/O error occursMathIllegalStateException
- if mode is not recognizedMathIllegalArgumentException
- if the underlying random generator thwrows onepublic void fill(double[] values) throws IOException, MathIllegalStateException, MathIllegalArgumentException
values
- array to be filledIOException
- in REPLAY_MODE if a file I/O error occursMathIllegalStateException
- if mode is not recognizedMathIllegalArgumentException
- if the underlying random generator thwrows onepublic double[] fill(int length) throws IOException, MathIllegalStateException, MathIllegalArgumentException
length
with values generated
using getNext() repeatedly.length
- length of output arrayIOException
- in REPLAY_MODE if a file I/O error occursMathIllegalStateException
- if mode is not recognizedMathIllegalArgumentException
- if the underlying random generator thwrows onepublic void computeDistribution() throws IOException, ZeroException, NullArgumentException
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
IOException
- if an I/O error occurs reading the input fileNullArgumentException
- if the valuesFileURL
has not been setZeroException
- if URL contains no datapublic void computeDistribution(int binCount) throws NullArgumentException, IOException, ZeroException
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
binCount
- the number of bins used in computing the empirical
distributionNullArgumentException
- if the valuesFileURL
has not been setIOException
- if an error occurs reading the input fileZeroException
- if URL contains no datapublic int getMode()
the class javadoc
for description of the valid values of this property.public void setMode(int mode)
mode
- New value of the data generation mode.public URL getValuesFileURL()
DIGEST_MODE
.public void setValuesFileURL(String url) throws MalformedURLException
values file URL
using a string
URL representation.url
- String representation for new valuesFileURL.MalformedURLException
- if url is not well formedpublic void setValuesFileURL(URL url)
values file URL
.
The values file must be an ASCII text file containing one valid numeric entry per line.
url
- URL of the values file.public EmpiricalDistribution getEmpiricalDistribution()
EmpiricalDistribution
used when operating in 0.computeDistribution()
public void resetReplayFile() throws IOException
valuesFileURL
.IOException
- if an error occurs opening the fileNullPointerException
- if the valuesFileURL
has not been set.public void closeReplayFile() throws IOException
valuesFileURL
after use in REPLAY_MODE.IOException
- if an error occurs closing the filepublic double getMu()
GAUSSIAN_MODE
, EXPONENTIAL_MODE
or UNIFORM_MODE
. When operating in CONSTANT_MODE
, this is the constant
value always returned. Calling computeDistribution()
sets this value to the
overall mean of the values in the values file
.public void setMu(double mu)
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
.mu
- new Mean value.public double getSigma()
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
.GAUSSIAN_MODE
.public void setSigma(double sigma)
standard deviation
used in GAUSSIAN_MODE
.sigma
- New standard deviation.public void reSeed(long seed)
seed
- Value with which to reseed the RandomDataImpl
used to generate random data.Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.