

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object gov.sandia.cognition.util.AbstractCloneableSerializable gov.sandia.cognition.math.AbstractRing<RandomVariable<DataType>> gov.sandia.cognition.statistics.AbstractRandomVariable<Number> gov.sandia.cognition.statistics.UnivariateRandomVariable
@PublicationReference(author="Wikipedia", title="Algebra of random variables", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Algebra_of_random_variables") public class UnivariateRandomVariable
This is an implementation of a RandomVariable for scalar distributions. The primary method by which randomvariable algebra is conducted is by empirically sampling the distributions, performing the algebra on the samples, and then fitting an empirical distribution to the resulting samples.
Field Summary  

static int 
DEFAULT_NUM_SAMPLES
Default number of samples to draw from a distribution to perform the empirical algebra approximation, 10000. 
Constructor Summary  

UnivariateRandomVariable(UnivariateDistribution<? extends Number> distribution,
Random random)
Creates a new instance of UnivariateRandomVariable 

UnivariateRandomVariable(UnivariateDistribution<? extends Number> distribution,
Random random,
int numSamples)
Creates a new instance of UnivariateRandomVariable 
Method Summary  

UnivariateRandomVariable 
clone()
This makes public the clone method on the Object class and
removes the exception that it throws. 
void 
dotTimesEquals(RandomVariable<Number> other)
Inline elementwise multiplication of this and
other 
boolean 
equals(Object obj)
Determines if two RingType objects are equal 
boolean 
equals(RandomVariable<Number> other,
double effectiveZero)
Determines if two RingType objects are effectively equal 
CumulativeDistributionFunction<Number> 
getCDF()
Gets the CDF of a scalar distribution. 
UnivariateDistribution<? extends Number> 
getDistribution()
Getter for distribution 
Double 
getMaxSupport()
Gets the minimum support (domain or input) of the distribution. 
Number 
getMean()
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution. 
Double 
getMinSupport()
Gets the minimum support (domain or input) of the distribution. 
int 
getNumSamples()
Getter for numSamples 
Random 
getRandom()
Gets the random number generator used by this object. 
ConfidenceInterval 
getSamplingError(double confidence)
Gets the 95% confidence interval estimated sampling error associated with this empirical random variable. 
double 
getVariance()
Gets the variance of the distribution. 
boolean 
isZero(double effectiveZero)
Determines if this ring is equal to zero using the elementwise effective zero value. 
void 
minusEquals(RandomVariable<Number> other)
Inline arithmetic subtraction of other from
this 
void 
plusEquals(RandomVariable<Number> other)
Inline arithmetic addition of this and other 
ArrayList<Number> 
sample(Random random,
int numSamples)
Draws multiple random samples from the distribution. 
void 
scaledPlusEquals(double scaleFactor,
RandomVariable<Number> other)
Inline arithmetic addition of this and other after
elementwise scaling of other by scaleFactor . 
void 
scaleEquals(double scaleFactor)
Inline elementwise scaling of this by
scaleFactor 
void 
setDistribution(UnivariateDistribution<? extends Number> distribution)
Setter for distribution 
void 
setNumSamples(int numSamples)
Setter for numSamples 
void 
setRandom(Random random)
Sets the random number generator used by this object. 
Methods inherited from class gov.sandia.cognition.statistics.AbstractRandomVariable 

sample 
Methods inherited from class gov.sandia.cognition.math.AbstractRing 

dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus, zero 
Methods inherited from class java.lang.Object 

finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Methods inherited from interface gov.sandia.cognition.statistics.Distribution 

sample 
Methods inherited from interface gov.sandia.cognition.math.Ring 

dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus, zero 
Field Detail 

public static final int DEFAULT_NUM_SAMPLES
Constructor Detail 

public UnivariateRandomVariable(UnivariateDistribution<? extends Number> distribution, Random random)
distribution
 Scalar distribution that backs the random variable, from which samples
will be drawn to approximate the distribution during algebra.random
 Random number generator used to sample the distributionpublic UnivariateRandomVariable(UnivariateDistribution<? extends Number> distribution, Random random, int numSamples)
distribution
 Scalar distribution that backs the random variable, from which samples
will be drawn to approximate the distribution during algebra.random
 Random number generator used to sample the distributionnumSamples
 Method Detail 

public UnivariateRandomVariable clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.
clone
in interface Ring<RandomVariable<Number>>
clone
in interface CloneableSerializable
clone
in class AbstractRing<RandomVariable<Number>>
public boolean equals(Object obj)
Ring
equals
in interface Ring<RandomVariable<Number>>
equals
in class Object
obj
 RingType to compare against this
public boolean equals(RandomVariable<Number> other, double effectiveZero)
Ring
equals
in interface Ring<RandomVariable<Number>>
other
 RingType to compare against this
effectiveZero
 tolerance threshold for elementwise equality
public void plusEquals(RandomVariable<Number> other)
Ring
this
and other
plusEquals
in interface Ring<RandomVariable<Number>>
other
 object to add to this
public void minusEquals(RandomVariable<Number> other)
Ring
other
from
this
minusEquals
in interface Ring<RandomVariable<Number>>
other
 object to subtract from this
public void dotTimesEquals(RandomVariable<Number> other)
Ring
this
and
other
dotTimesEquals
in interface Ring<RandomVariable<Number>>
other
 elements of other will be multiplied to the corresponding
elements of this
public void scaleEquals(double scaleFactor)
Ring
this
by
scaleFactor
scaleEquals
in interface Ring<RandomVariable<Number>>
scaleFactor
 amount to scale the elements of this
public void scaledPlusEquals(double scaleFactor, RandomVariable<Number> other)
Ring
this
and other
after
elementwise scaling of other
by scaleFactor
.
If this is x, other is y, and scaleFactor is a, then this method is
equivalent to x += a * y. It is typically a more efficient way of doing
this.plusEquals(other.scale(scaleFactor))
since it can avoid
intermediate object creation.
scaledPlusEquals
in interface Ring<RandomVariable<Number>>
scaleFactor
 The scale factor to multiply by the elements of other before
adding to the elements of this.other
 Object to scale and then add to this.public boolean isZero(double effectiveZero)
Ring
isZero
in interface Ring<RandomVariable<Number>>
effectiveZero
 Tolerance threshold for elementwise equality
public ArrayList<Number> sample(Random random, int numSamples)
Distribution
sample
in interface Distribution<Number>
random
 Randomnumber generator to use in order to generate random numbers.numSamples
 Number of samples to draw from the distribution.
public int getNumSamples()
public void setNumSamples(int numSamples)
numSamples
 Number of samples to draw from the distribution to perform the
empirical algebra approximation.public Random getRandom()
Randomized
getRandom
in interface Randomized
public void setRandom(Random random)
Randomized
setRandom
in interface Randomized
random
 The random number generator for this object to use.public UnivariateDistribution<? extends Number> getDistribution()
public void setDistribution(UnivariateDistribution<? extends Number> distribution)
distribution
 Scalar distribution that backs the random variable, from which samples
will be drawn to approximate the distribution during algebra.public Number getMean()
DistributionWithMean
getMean
in interface DistributionWithMean<Number>
public double getVariance()
UnivariateDistribution
getVariance
in interface UnivariateDistribution<Number>
public Double getMinSupport()
UnivariateDistribution
getMinSupport
in interface UnivariateDistribution<Number>
public Double getMaxSupport()
UnivariateDistribution
getMaxSupport
in interface UnivariateDistribution<Number>
@PublicationReference(author="Wikipedia", title="Standard error (statistics)", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Standard_error_(statistics)") public ConfidenceInterval getSamplingError(double confidence)
confidence
 Confidence required. If you want 95% confidence, which is the standard
in social science, then use 0.95.
public CumulativeDistributionFunction<Number> getCDF()
UnivariateDistribution
getCDF
in interface UnivariateDistribution<Number>


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 