Statistics
Class RandomVariable

java.lang.Object
  extended byStatistics.RandomVariable
Direct Known Subclasses:
BetaVariable, BinomialVariable, ChiSquareVariable, ControlledRandomVariable, EmpiricalRandomVariable, ExponentialVariable, GammaVariable, HyperGeometricVariable, NegativeBinomialVariable, NormalVariable, PathFunctional, PoissonVariable, PoissonVariable

public abstract class RandomVariable
extends java.lang.Object

This class implements methods to compute conditional and unconditional expectations, standard deviations and other statistics and histograms of a random variable X (this). The information to condition on is parametrized by the discrete time parameter t (see below).

All methods are defined in terms of the abstract method getValue(int). A RandomVariable can be instantiated as soon as this method is defined.

Information: Random variables X are often observed in a context with increasing information becoming available about X as time t passes. Clearly one will draw from the distribution of X by conditioning on this information.

Exactly what information is available at time t and how to condition on it is context specific and handled by the implementations. If no information about X is available the parameter t is simply not used and so unconditional statistics computed.

Frequently this information is the realized path of a stochastic process up to time t and conditioning on this information means considering only paths which branch from the current path at time t.

Empirical distribution: the empirical distribution empiricalDistribution(int) of X links us with the colt library.

It is extends the most powerful dynamic container for data samples of this library with a number of efficient statistics which are not computed incrementally but derived from the sample set which is stored internally. This consumes memory. Thus the field empiricalDist is initialized only when it is needed the first time. Thereafter the sample size is increased as needed.


Constructor Summary
RandomVariable()
          Default constructor, no analytic formulas, empiricalDistribution not initialized.
RandomVariable(boolean hasAnalyticMean, boolean hasConditionalAnalyticMean, boolean hasAnalyticVariance, boolean hasConditionalAnalyticVariance, boolean hasAnalyticMoment, boolean hasConditionalAnalyticMoment, boolean hasAnalyticCentralMoment, boolean hasConditionalAnalyticCentralMoment)
          Use this constructor from a subclass to override the default constructor in case analytic formulas for some statistics associated with X exist.
 
Method Summary
 double analyticCentralMoment(int n)
          Unconditional central moment of order n given by exact formula.
 double analyticConditionalCentraMoment(int t, int n)
          Central moment of order n conditioned on information available time t given by exact formula.
 double analyticConditionalMean(int t)
          Mean conditioned on information available time t given by exact formula.
 double analyticConditionalMoment(int t, int n)
          Moment of order n conditioned on information available time t given by exact formula.
 double analyticConditionalVariance(int t)
          Variance conditioned on information available time t given by exact formula.
 double analyticMean()
          Unconditional mean given by exact formula.
 double analyticMoment(int n)
          Unconditional moment of order n given by exact formula.
 double analyticVariance()
          Unconditional variance given by exact formula.
 BasicHistogram basicHistogram(int N, int nBins, double tail, boolean smoothed)
          Returns a BasicHistogram (for plotting with Scigraphica or the Gri graphing language).
 RandVariable centered_X(int t, int n, int N)
          The centered power (X-E_t(X))^n of the random variable X (this) conditioned on information available at time t.
 EmpiricalDistribution conditionalEmpiricalDistribution(int t, int N)
          The EmpiricalDistribution of X (this) conditioned on information available at time t.
 double conditionalExpectation(int t, double precision, double confidence)
          Same as conditionalExpectation(int,int) but sample size increased until desired precision is reached with desired confidence.
 double conditionalExpectation(int t, double precision, double confidence, int sampleGroupSize)
          Same as conditionalExpectation(int,double,double) but samples come in groups of dependent samples of size sampleGroupSize.
 double conditionalExpectation(int t, int N)
          Expectation conditioned on information available time t and computed from sample of size N.
 double conditionalExpectation(int t, int N, boolean report)
          Expectation conditioned on information available time t and computed from sample of size N.
 double conditionalExpectation(int t, int N, int m, javax.swing.JProgressBar jPrgBar)
          Same as conditionalExpectation(int,int) but with computational progress reported to a progress bar.
 jas.hist.JASHist conditionalHistogram(int t, int N, int nBins, boolean smoothBinHeights)
          Same as displayConditionalHistogram(int,int,int,boolean,String,String) but no title or axis labels.
 jas.hist.JASHist conditionalHistogram(int t, int N, int nBins, boolean smoothBinHeights, java.lang.String title, java.lang.String xAxisLabel)
          Returns a normalized histogram of a sample of size N of X conditioned on information available at time t.
 double[] conditionalMeanAndStandardDeviation(int t, int N)
          Mean (return_value[0]) and standard deviation (return_value[1]) conditioned on information available at time t and computed from sample of size N.
 double[] conditionalMeanAndStandardDeviation(int t, int N, int sampleGroupSize)
          Mean (return_value[0]) and standard deviation (return_value[1]) of the sample group means of the random variable X (this) conditioned on information available at time.
 double[] conditionalMeanAndStandardDeviation(int t, int N, int m, int sampleGroupSize, javax.swing.JProgressBar jPrgBar)
          Same as conditionalMeanAndStandardDeviation(int,int,int) but with computational progress reported to a progress bar.
 double[] conditionalMeanAndStandardDeviation(int t, int N, int m, javax.swing.JProgressBar jPrgBar)
          Same as conditionalMeanAndStandardDeviation(int, int) but with computational progress reported to a progress bar.
 double conditionalMoment(int t, int n, int N)
          The moment of order n computed from a sample of size N and conditioned on information available time t.
 double conditionalVariance(int t, int N)
          Variance conditioned on information available at time t and computed from a sample of size N.
 double cumulativeDistributionFunction(double x, int N)
          Returns Prob(X<=x) computed from a sample of size max{ N, empiricalDist.nSamples }.
 void displayConditionalHistogram(int t, int N, int nBins, boolean smoothBinHeights)
          Same as displayConditionalHistogram(int,int,int,,boolean,String,String) but no title or axis labels.
 void displayConditionalHistogram(int t, int N, int nBins, boolean smoothBinHeights, java.lang.String filename, int filetype)
          Same as displayConditionalHistogram(int,int,int,boolean,String,String,String,int) but no title or axis labels.
 void displayConditionalHistogram(int t, int N, int nBins, boolean smoothBinHeights, java.lang.String title, java.lang.String xAxisLabel)
          Displays a normalized histogram of a sample of size N of X conditioned on information available at time t in a JFrame window.
 void displayConditionalHistogram(int t, int N, int nBins, boolean smoothBinHeights, java.lang.String title, java.lang.String xAxisLabel, java.lang.String filename, int filetype)
          Displays a normalized histogram of a sample of size N of X conditioned on information available at time t in a JFrame window then saves the histogram to a file.
 void displayHistogram(int N, int nBins, boolean smoothBinHeights)
          Displays an unconditional histogram.
 void displayHistogram(int N, int nBins, boolean smoothBinHeights, java.lang.String filename, int filetype)
          Displays an unconditional histogram.
 void displayHistogram(int N, int nBins, boolean smoothBinHeights, java.lang.String title, java.lang.String xAxisLabel)
          Displays an unconditional histogram.
 void displayHistogram(int N, int nBins, boolean smoothBinHeights, java.lang.String title, java.lang.String xAxisLabel, java.lang.String filename, int filetype)
          Displays an unconditional histogram.
 RandomVariable div(RandomVariable Y)
          Returns the variable Z=X/Y, where X is the current random variable this.
 EmpiricalDistribution empiricalDistribution(int N)
          Unconditional empirical distribution of X (this).
 double expectation(double precision, double confidence)
          Same as conditionalExpectation(int,double,double) but no information to condition on.
 double expectation(double precision, double confidence, int sampleGroupSize)
          Same as conditionalExpectation(int,double,double,int) but no information to condition on.
 double expectation(int N)
          Unconditional expectation computed from sample of size N.
 double expectation(int N, boolean report)
          Unconditional expectation computed from sample of size N.
 double expectation(int N, int m, javax.swing.JProgressBar jPrgBar)
          Same as expectation(int) but with computational progress reported to a progress bar.
 void fillSampleSet(int N)
          Increases the size of the set of samples of X (this) stored in the unconditional empirical distribution of X to N.
 boolean get_empiricalDistributionIsInitialized()
          True if the empirical distribution has been initilized (filled with samples) false else.
 boolean get_hasAnalyticCentralMoment()
          True if analytic formula for the unconditional mean implemented false else.
 boolean get_hasAnalyticMean()
          True if an analytic formula for the unconditional mean is implemented false else.
 boolean get_hasAnalyticMoment()
          True if analytic formula for the unconditional mean implemented false else.
 boolean get_hasAnalyticVariance()
          True if an analytic formula for the unconditional variance is implemented false else.
 boolean get_hasConditionalAnalyticCentralMoment()
          True if analytic formula for the unconditional mean implemented false else.
 boolean get_hasConditionalAnalyticMean()
          True if analytic formula for the conditional mean is implemented false else.
 boolean get_hasConditionalAnalyticMoment()
          True if analytic formula for the unconditional mean implemented false else.
 boolean get_hasConditionalAnalyticVariance()
          True if an analytic formula for the conditional variance is implemented false else.
abstract  double getValue(int t)
          A new sample from the distribution of X conditioned on information available at time t.
 jas.hist.JASHist histogram(int N, int nBins, boolean smoothBinHeights)
          Unconditional histogram.
 jas.hist.JASHist histogram(int N, int nBins, boolean smoothBinHeights, java.lang.String title, java.lang.String xAxisLabel)
          Unconditional histogram.
 void initEmpiricalDistribution(int N)
          Initializes the empirical distribution (field empiricalDist) of X (this) with N samples.
static void main(java.lang.String[] args)
          Test program.
 double[] meanAndStandardDeviation(int N)
          Unconditional mean (return_value[0]) and standard deviation (return_value[1]) computed from sample of size N.
 double[] meanAndStandardDeviation(int N, int sampleGroupSize)
          Same as conditionalMeanAndStandardDeviation(int,int,int), but no information to condition on.
 double[] meanAndStandardDeviation(int N, int m, int sampleGroupSize, javax.swing.JProgressBar jPrgBar)
          Same as (int,int,int,int,JProgressBar) but no information to condition on.
 double[] meanAndStandardDeviation(int N, int m, javax.swing.JProgressBar jPrgBar)
          Same as meanAndStandardDeviation(int) but with computational progress reported to a progress bar.
 RandomVariable minus(RandomVariable Y)
          Returns the variable Z=X-Y, where X is the current random variable this.
 RandomVariable mult(RandomVariable Y)
          Returns the variable Z=X*Y, where X is the current random variable this.
 RandomVariable plus(RandomVariable Y)
          Returns the variable Z=X+Y, where X is the current random variable this.
 double quantile(double phi, int N)
          Computes the phi-quantile (0< phi < 1), that is, the smallest x such that Prob(X<=x)=phi from a sample of size max{ N, empiricalDist.nSamples }.
 RandomVariable scale(double lambda)
          Returns the variable Z=lambda*X, where X is the current random variable this.
 void setHasAnalyticMean(boolean value)
           
 void setHasAnalyticVariance(boolean value)
           
 double variance(int N)
          Variance computed from a sample of size N.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomVariable

public RandomVariable()

Default constructor, no analytic formulas, empiricalDistribution not initialized.


RandomVariable

public RandomVariable(boolean hasAnalyticMean,
                      boolean hasConditionalAnalyticMean,
                      boolean hasAnalyticVariance,
                      boolean hasConditionalAnalyticVariance,
                      boolean hasAnalyticMoment,
                      boolean hasConditionalAnalyticMoment,
                      boolean hasAnalyticCentralMoment,
                      boolean hasConditionalAnalyticCentralMoment)

Use this constructor from a subclass to override the default constructor in case analytic formulas for some statistics associated with X exist.

Parameters:
hasAnalyticMean - An analytic formula exists for the mean (T/F)?
hasConditionalAnalyticMean - An analytic formula exists for the conditional mean (T/F)?
Method Detail

get_hasAnalyticMean

public boolean get_hasAnalyticMean()
True if an analytic formula for the unconditional mean is implemented false else.


get_hasConditionalAnalyticMean

public boolean get_hasConditionalAnalyticMean()
True if analytic formula for the conditional mean is implemented false else.


get_hasAnalyticVariance

public boolean get_hasAnalyticVariance()
True if an analytic formula for the unconditional variance is implemented false else.


get_hasConditionalAnalyticVariance

public boolean get_hasConditionalAnalyticVariance()
True if an analytic formula for the conditional variance is implemented false else.


get_hasAnalyticMoment

public boolean get_hasAnalyticMoment()
True if analytic formula for the unconditional mean implemented false else.


get_hasConditionalAnalyticMoment

public boolean get_hasConditionalAnalyticMoment()
True if analytic formula for the unconditional mean implemented false else.


get_hasAnalyticCentralMoment

public boolean get_hasAnalyticCentralMoment()
True if analytic formula for the unconditional mean implemented false else.


get_hasConditionalAnalyticCentralMoment

public boolean get_hasConditionalAnalyticCentralMoment()
True if analytic formula for the unconditional mean implemented false else.


setHasAnalyticMean

public void setHasAnalyticMean(boolean value)

setHasAnalyticVariance

public void setHasAnalyticVariance(boolean value)

getValue

public abstract double getValue(int t)

A new sample from the distribution of X conditioned on information available at time t.

This is the crucial method defining the random variable and information structure.

Parameters:
t - Current time (determines information to condition on.)

analyticConditionalMean

public double analyticConditionalMean(int t)

Mean conditioned on information available time t given by exact formula.

Since in general there are no analytic formulas the default is an error message and abort. Override this in special cases where analytic formulas do exist.

Parameters:
t - current time (determines information to condition on).

analyticMean

public double analyticMean()

Unconditional mean given by exact formula.

Since in general there are no analytic formulas the default is an error message and program abort. Override this in special cases where analytic formulas do exist.


analyticConditionalVariance

public double analyticConditionalVariance(int t)

Variance conditioned on information available time t given by exact formula.

Since in general there are no analytic formulas the default is an error message and program abort. Override this in special cases where analytic formulas do exist.

Parameters:
t - current time (determines information to condition on).

analyticVariance

public double analyticVariance()

Unconditional variance given by exact formula.

Since in general there are no analytic formulas the default is an error message and program abort. Override this in special cases where analytic formulas do exist.


analyticConditionalMoment

public double analyticConditionalMoment(int t,
                                        int n)

Moment of order n conditioned on information available time t given by exact formula.

Since in general there are no analytic formulas the default is an error message and program abort. Override this in special cases where analytic formulas do exist.

Parameters:
t - current time.
n - order of moment.

analyticMoment

public double analyticMoment(int n)

Unconditional moment of order n given by exact formula.

Since in general there are no analytic formulas the default is an error message and program abort. Override this in special cases where analytic formulas exist.

Parameters:
n - order of moment.

analyticConditionalCentraMoment

public double analyticConditionalCentraMoment(int t,
                                              int n)

Central moment of order n conditioned on information available time t given by exact formula.

Since in general there are no analytic formulas the default is an error message and program abort. Override this in special cases where analytic formulas do exist.

Parameters:
t - current time.
n - order of central moment.

analyticCentralMoment

public double analyticCentralMoment(int n)

Unconditional central moment of order n given by exact formula.

Since in general there are no analytic formulas the default is an error message and program abort. Override this in special cases where analytic formulas do exist.

Parameters:
n - order of central moment.

conditionalExpectation

public double conditionalExpectation(int t,
                                     int N)

Expectation conditioned on information available time t and computed from sample of size N.

Parameters:
t - Current time (determines information to condition on).
N - Sample size.

expectation

public double expectation(int N)

Unconditional expectation computed from sample of size N.

Parameters:
N - Sample size.

conditionalExpectation

public double conditionalExpectation(int t,
                                     int N,
                                     boolean report)

Expectation conditioned on information available time t and computed from sample of size N.

Parameters:
t - Current time (determines information to condition on).
N - Sample size.
report - dummy parameter, this method always delivers the report

expectation

public double expectation(int N,
                          boolean report)

Unconditional expectation computed from sample of size N.

Parameters:
N - Sample size.
report - dummy parameter, report is always delivered.

conditionalMeanAndStandardDeviation

public double[] conditionalMeanAndStandardDeviation(int t,
                                                    int N)

Mean (return_value[0]) and standard deviation (return_value[1]) conditioned on information available at time t and computed from sample of size N.

Parameters:
t - current time (determines information to condition on)
N - sample size

meanAndStandardDeviation

public double[] meanAndStandardDeviation(int N)

Unconditional mean (return_value[0]) and standard deviation (return_value[1]) computed from sample of size N.

Parameters:
N - Sample size.

conditionalMeanAndStandardDeviation

public double[] conditionalMeanAndStandardDeviation(int t,
                                                    int N,
                                                    int sampleGroupSize)

Mean (return_value[0]) and standard deviation (return_value[1]) of the sample group means of the random variable X (this) conditioned on information available at time.

Samples come in groups of size sampleGroupSize where samples across groups are independent but samples in the same group are not.

WARNING: This computes the standard deviation of the sample group means and not the standard deviation of X. This is the standard deviation controlling confidence intervals for the mean of X computed as a mean of sample group means.

.

[N/sampleGroupSize] groups are simulated. Here [x] denotes the greatest integer <= x. Consequently the number of samples generated is given by

sampleGroupSize*[N/sampleGroupSize]=N-(N % sampleGroupSize)

Note: the simulation must be set to start a new sample group before calling this routine.

Parameters:
t - Current time (determines information to condition on).
N - Sample size.
sampleGroupSize - Size of groups of dependent samples.

meanAndStandardDeviation

public double[] meanAndStandardDeviation(int N,
                                         int sampleGroupSize)
Same as conditionalMeanAndStandardDeviation(int,int,int), but no information to condition on.


conditionalExpectation

public double conditionalExpectation(int t,
                                     int N,
                                     int m,
                                     javax.swing.JProgressBar jPrgBar)

Same as conditionalExpectation(int,int) but with computational progress reported to a progress bar.

Parameters:
t - Current time (determines information to condition on).
N - Sample size.
m - Progress report updated every m samples.
jPrgBar - Target of progress report.

expectation

public double expectation(int N,
                          int m,
                          javax.swing.JProgressBar jPrgBar)

Same as expectation(int) but with computational progress reported to a progress bar.

Parameters:
N - Sample size.
m - Progress report updated every mth sample.
jPrgBar - Target of progress report.

conditionalMeanAndStandardDeviation

public double[] conditionalMeanAndStandardDeviation(int t,
                                                    int N,
                                                    int m,
                                                    javax.swing.JProgressBar jPrgBar)

Same as conditionalMeanAndStandardDeviation(int, int) but with computational progress reported to a progress bar.

Parameters:
t - Current time (determines information to condition on).
N - Sample size
m - Progress report updated every m samples
jPrgBar - Target of progress report

meanAndStandardDeviation

public double[] meanAndStandardDeviation(int N,
                                         int m,
                                         javax.swing.JProgressBar jPrgBar)

Same as meanAndStandardDeviation(int) but with computational progress reported to a progress bar.

Parameters:
N - Sample size.
m - Progress report updated every m samples.
jPrgBar - Target of progress report.

conditionalMeanAndStandardDeviation

public double[] conditionalMeanAndStandardDeviation(int t,
                                                    int N,
                                                    int m,
                                                    int sampleGroupSize,
                                                    javax.swing.JProgressBar jPrgBar)

Same as conditionalMeanAndStandardDeviation(int,int,int) but with computational progress reported to a progress bar.

Parameters:
t - Current time (determines information to condition on).
N - Sample size.
m - Progress report updated every m samples
sampleGroupSize - Size of groups of dependent samples.
jPrgBar - Target of progress report.

meanAndStandardDeviation

public double[] meanAndStandardDeviation(int N,
                                         int m,
                                         int sampleGroupSize,
                                         javax.swing.JProgressBar jPrgBar)

Same as (int,int,int,int,JProgressBar) but no information to condition on.

Parameters:
N - Sample size.
m - Progress report updated every m samples.
sampleGroupSize - Size of groups of dependent samples.
jPrgBar - Target of progress report.

conditionalExpectation

public double conditionalExpectation(int t,
                                     double precision,
                                     double confidence)

Same as conditionalExpectation(int,int) but sample size increased until desired precision is reached with desired confidence.

Generates at least 100 samples until precision or a maximum of 1000000 samples are reached.

Parameters:
t - Current time (determines information to condition on).
precision - Bound on absolute error
confidence - Probability that error bound is met.

expectation

public double expectation(double precision,
                          double confidence)

Same as conditionalExpectation(int,double,double) but no information to condition on.

Parameters:
precision - Bound on absolute error.
confidence - Probability that error bound is met.

conditionalExpectation

public double conditionalExpectation(int t,
                                     double precision,
                                     double confidence,
                                     int sampleGroupSize)

Same as conditionalExpectation(int,double,double) but samples come in groups of dependent samples of size sampleGroupSize.

Note: the simulation must be set to start a new sample group before calling this routine.

Parameters:
t - Current time (determines information to condition on).
precision - Bound on absolute error.
confidence - Probability that error bound is met.
sampleGroupSize - Size of groups of dependent samples.

expectation

public double expectation(double precision,
                          double confidence,
                          int sampleGroupSize)

Same as conditionalExpectation(int,double,double,int) but no information to condition on.

Parameters:
precision - Bound on absolute error.
confidence - Probability that error bound is met.
sampleGroupSize - Size of groups of dependent samples.

conditionalVariance

public double conditionalVariance(int t,
                                  int N)

Variance conditioned on information available at time t and computed from a sample of size N.

Recall that Var(X)=E(X^2)-E(X)^2.

Parameters:
t - Current time (determines information to condition on).
N - Size of sample used to estimate the variance.

variance

public double variance(int N)

Variance computed from a sample of size N.

Parameters:
N - Size of sample used to estimate the variance.

conditionalMoment

public double conditionalMoment(int t,
                                int n,
                                int N)

The moment of order n computed from a sample of size N and conditioned on information available time t.

Recall that the moment of order n of X is simply E(X^n).

Parameters:
t - Current time (determines information to condition on).
n - Order of the moment.
N - Size of sample used to estimate the moment.

centered_X

public RandVariable centered_X(int t,
                               int n,
                               int N)

The centered power (X-E_t(X))^n of the random variable X (this) conditioned on information available at time t.

Note that t is a parameter of centered_X. No conditioning occurs in the random variable centered_X(t). It is already the version of X conditioned on information available at time t.

This random variable is allocated as an object of type RandVariable not RandomVariable to avoid recursion.

Parameters:
t - current time.
n - exponent.
N - size of sample group to compute the mean.

get_empiricalDistributionIsInitialized

public boolean get_empiricalDistributionIsInitialized()
True if the empirical distribution has been initilized (filled with samples) false else.


initEmpiricalDistribution

public void initEmpiricalDistribution(int N)

Initializes the empirical distribution (field empiricalDist) of X (this) with N samples. Does nothing if the field is already initialized, even if is initialized with fewer samples. In this case fillSampleSet(int).

The empirical distribution stores all samples internally and so consumes much memory. Therefore this field is only initilaized when needed for the first time and thereafter the sample set is increased as needed.

Parameters:
N - number of samples of X filled in.

fillSampleSet

public void fillSampleSet(int N)

Increases the size of the set of samples of X (this) stored in the unconditional empirical distribution of X to N.

Initializes the empirical distribution if it has not been initialized. Does nothing if the sample size is already N or greater (see initEmpiricalDistribution(int)).

Parameters:
N - level to which sample size in (unconditional) empirical distribution is increased.

conditionalEmpiricalDistribution

public EmpiricalDistribution conditionalEmpiricalDistribution(int t,
                                                              int N)

The EmpiricalDistribution of X (this) conditioned on information available at time t.

Parameters:
t - current time (determines information to condition on).
N - sample size (number of samples of X filled in).

empiricalDistribution

public EmpiricalDistribution empiricalDistribution(int N)

Unconditional empirical distribution of X (this). Simply returns a reference to the field empiricalDist where this distribution is kept. Initializes the field if it is not initialized. The field is not initialized automatically since it consumes much memory.

Parameters:
N - sample size (number of samples of X filled in).

quantile

public double quantile(double phi,
                       int N)

Computes the phi-quantile (0< phi < 1), that is, the smallest x such that Prob(X<=x)=phi from a sample of size max{ N, empiricalDist.nSamples }.

This makes use of the class hep.aida.bin.QuantileBin1D which is part of the colt library (http//:tilde-hoschek.home.cern.ch./~hoschek/colt/).

Parameters:
phi - percentage (must be in (0,1)) for which the quantile is computed.
N - minimum size of sample from which the quantile is computed.

cumulativeDistributionFunction

public double cumulativeDistributionFunction(double x,
                                             int N)

Returns Prob(X<=x) computed from a sample of size max{ N, empiricalDist.nSamples }. Here X is the random variable this.

This makes use of the class hep.aida.bin.QuantileBin1D which is part of the colt library (http//:tilde-hoschek.home.cern.ch./~hoschek/colt/).

Parameters:
x - a real number (double).

basicHistogram

public BasicHistogram basicHistogram(int N,
                                     int nBins,
                                     double tail,
                                     boolean smoothed)

Returns a BasicHistogram (for plotting with Scigraphica or the Gri graphing language). No conditioning, time t=0.

Parameters:
N - sample size (number of samples of X filled in).
nBins - number of histogram bins.
tail - in (0,1/2), the bins in the two 100*tail% extreme quartiles lumped into one bin each.
smoothed - wether or not bin heights are to be smoothed.

conditionalHistogram

public jas.hist.JASHist conditionalHistogram(int t,
                                             int N,
                                             int nBins,
                                             boolean smoothBinHeights,
                                             java.lang.String title,
                                             java.lang.String xAxisLabel)

Returns a normalized histogram of a sample of size N of X conditioned on information available at time t.

Progress on filling the histogram is reported to a progress bar and displayed in a JFrame window (updated 200 times). This happens in the class FixedBinDataSource.

Based on the plotting functionality of the class jas.hist.JASHist, see java analysis studio.

Parameters:
t - current time (determines information to condition on).
N - sample size (number of samples of X filled in).
nBins - number of histogram bins.
smoothBinHeights - see smoothed.
title - title displayed.
xAxisLabel - label displayed on x-axis.

conditionalHistogram

public jas.hist.JASHist conditionalHistogram(int t,
                                             int N,
                                             int nBins,
                                             boolean smoothBinHeights)

Same as displayConditionalHistogram(int,int,int,boolean,String,String) but no title or axis labels.

Parameters:
t - current time (determines information to condition on).
N - sample size (number of samples of X filled in).
nBins - number of bins.
smoothBinHeights - see smoothed.

histogram

public jas.hist.JASHist histogram(int N,
                                  int nBins,
                                  boolean smoothBinHeights,
                                  java.lang.String title,
                                  java.lang.String xAxisLabel)
Unconditional histogram. same as displayConditionalHistogram(int,int,int,boolean,String,String) but no information to condition on (t=0).

Parameters:
N - sample size (number of samples of X filled in).
nBins - number of histogram bins.
smoothBinHeights - see smoothed.
title - title displayed.
xAxisLabel - label displayed on x-axis.

histogram

public jas.hist.JASHist histogram(int N,
                                  int nBins,
                                  boolean smoothBinHeights)

Unconditional histogram. Same as displayHistogram(int,int,,boolean,String,String) but no title or xAxisLabel.

Parameters:
N - minimum sample size (number of samples of X filled in).
nBins - number of bins.
smoothBinHeights - see smoothed.

displayConditionalHistogram

public void displayConditionalHistogram(int t,
                                        int N,
                                        int nBins,
                                        boolean smoothBinHeights,
                                        java.lang.String title,
                                        java.lang.String xAxisLabel)

Displays a normalized histogram of a sample of size N of X conditioned on information available at time t in a JFrame window.

Progress on filling the histogram is reported to a progress bar and displayed in a JFrame window (updated 200 times). This happens in the class FixedBinDataSource.

Based on the plotting functionality of the class jas.hist.JASHist, see java analysis studio.

Parameters:
t - current time (determines information to condition on).
N - sample size (number of samples of X filled in).
nBins - number of histogram bins.
smoothBinHeights - see smoothed
title - title displayed.
xAxisLabel - label displayed on x-axis.

displayConditionalHistogram

public void displayConditionalHistogram(int t,
                                        int N,
                                        int nBins,
                                        boolean smoothBinHeights)

Same as displayConditionalHistogram(int,int,int,,boolean,String,String) but no title or axis labels.

Parameters:
t - current time (determines information to condition on).
N - sample size (number of samples of X filled in).
nBins - number of bins.
smoothBinHeights - see smoothed.

displayHistogram

public void displayHistogram(int N,
                             int nBins,
                             boolean smoothBinHeights,
                             java.lang.String title,
                             java.lang.String xAxisLabel)
Displays an unconditional histogram. same as displayConditionalHistogram(int,int,int,boolean,String,String) but no information to condition on (t=0).

Parameters:
N - sample size (number of samples of X filled in).
nBins - number of histogram bins.
title - title displayed.
xAxisLabel - label displayed on x-axis.

displayHistogram

public void displayHistogram(int N,
                             int nBins,
                             boolean smoothBinHeights)

Displays an unconditional histogram. Same as displayHistogram(int,int,boolean,String,String) but no title or xAxisLabel.

Parameters:
N - minimum sample size (number of samples of X filled in).
nBins - number of bins.

displayConditionalHistogram

public void displayConditionalHistogram(int t,
                                        int N,
                                        int nBins,
                                        boolean smoothBinHeights,
                                        java.lang.String title,
                                        java.lang.String xAxisLabel,
                                        java.lang.String filename,
                                        int filetype)

Displays a normalized histogram of a sample of size N of X conditioned on information available at time t in a JFrame window then saves the histogram to a file.

Progress on filling the histogram is reported to a progress bar and displayed in a JFrame window (updated 200 times). This happens in the class FixedBinDataSource.

Based on the plotting functionality of the class jas.hist.JASHist, see java analysis studio.

Parameters:
t - current time (determines information to condition on).
N - sample size (number of samples of X filled in).
nBins - number of histogram bins.
smoothBinHeights - see smoothed
title - title displayed.
xAxisLabel - label displayed on x-axis.
filename - path to file where the histogram is saved (all directories must exist).
filetype - currently only Flag.EPS (the default).

displayConditionalHistogram

public void displayConditionalHistogram(int t,
                                        int N,
                                        int nBins,
                                        boolean smoothBinHeights,
                                        java.lang.String filename,
                                        int filetype)

Same as displayConditionalHistogram(int,int,int,boolean,String,String,String,int) but no title or axis labels.

Parameters:
t - current time (determines information to condition on).
N - sample size (number of samples of X filled in).
nBins - number of bins.
smoothBinHeights - see smoothed.
filename - path to file where the histogram is saved (all directories must exist).
filetype - currently only EPS (the default).

displayHistogram

public void displayHistogram(int N,
                             int nBins,
                             boolean smoothBinHeights,
                             java.lang.String title,
                             java.lang.String xAxisLabel,
                             java.lang.String filename,
                             int filetype)
Displays an unconditional histogram. Same as displayConditionalHistogram(int,int,int,boolean,String,String,String,int) but no information to condition on (t=0).

Parameters:
N - sample size (number of samples of X filled in).
nBins - number of histogram bins.
title - title displayed.
xAxisLabel - label displayed on x-axis.
filename - path to file where the histogram is saved (all directories must exist).
filetype - currently only EPS (the default).

displayHistogram

public void displayHistogram(int N,
                             int nBins,
                             boolean smoothBinHeights,
                             java.lang.String filename,
                             int filetype)

Displays an unconditional histogram. Same as displayHistogram(int,int,boolean,String,String,String,int) but no title or xAxisLabel.

Parameters:
N - minimum sample size (number of samples of X filled in).
nBins - number of bins.
filename - path to file where the histogram is saved (all directories must exist).
filetype - currently only EPS (the default).

scale

public RandomVariable scale(double lambda)
Returns the variable Z=lambda*X, where X is the current random variable this. X is left unaffected.


plus

public RandomVariable plus(RandomVariable Y)
Returns the variable Z=X+Y, where X is the current random variable this. X is left unaffected.


minus

public RandomVariable minus(RandomVariable Y)
Returns the variable Z=X-Y, where X is the current random variable this. X is left unaffected.


mult

public RandomVariable mult(RandomVariable Y)
Returns the variable Z=X*Y, where X is the current random variable this. X is left unaffected.


div

public RandomVariable div(RandomVariable Y)
Returns the variable Z=X/Y, where X is the current random variable this. X is left unaffected. No checking for division by zero!


main

public static void main(java.lang.String[] args)
Test program. Allocates a normal variable and computes several quantities (Monte Carlo mean and variance, quantiles) aqnd compares to their known analytic values. Also displays both a smoothed and a nonsmoothed histogram for a sample of size 10000.