org.jmat.data
Class RandomMatrix

java.lang.Object
  |
  +--org.jmat.data.AbstractDoubleArray
        |
        +--org.jmat.data.AbstractMatrix
              |
              +--org.jmat.data.Matrix
                    |
                    +--org.jmat.data.RandomMatrix
All Implemented Interfaces:
ClipBoardPrintable, java.lang.Cloneable, CommandLinePrintable, FilePrintable, java.io.Serializable, StringPrintable, XMLPrintable

public class RandomMatrix
extends Matrix

The RandomMatrix Class provides tools for statistical simulations,it extends the Matrix Class and adds many methods.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jmat.data.AbstractDoubleArray
m, n
 
Constructor Summary
RandomMatrix(AbstractMatrix M)
          Construct an m-by-n matrix of 0.
RandomMatrix(int m, int n)
          Construct an m-by-n matrix of 0.
 
Method Summary
static RandomMatrix beta(int m, int n, double a, double b)
          Construct an m-by-n matrix of random numbers from a Beta random variable.
static RandomMatrix cauchy(int m, int n, double mu, double sigma)
          Construct an m-by-n matrix of random numbers from a Cauchy random variable.
 AbstractMatrix correlation()
          Generate a correlation matrix, each column contains values of a pulling.
 AbstractMatrix covariance()
          Generate a covariance matrix, each column contains values of a pulling.
static RandomMatrix dirac(int m, int n, AbstractMatrix val_prob)
          Construct an m-by-n matrix of random numbers from a discrete random variable.
static RandomMatrix exponential(int m, int n, double lambda)
          Construct an m-by-n matrix of random numbers from an exponantial random variable.
 boolean getIsSample()
          Specify if the RandomMatrix is a sample of an overall population, or if it's an overall population.
static RandomMatrix logNormal(int m, int n, double mu, double sigma)
          Construct an m-by-n matrix of random numbers from a LogNormal random variable.
 AbstractMatrix mean()
          Generate a row matrix, each column contents the mean value of the columns.
static RandomMatrix normal(int m, int n, double mu, double sigma)
          Construct an m-by-n matrix of random numbers from a Gaussian (Normal) random variable.
static RandomMatrix rejection(int m, int n, DoubleFunction fun, double min, double max)
          Construct an m-by-n matrix of random numbers from a random variable definied by its density function, using the rejection technic. !
static RandomMatrix sampleWithoutReplacement(int m, int n, Matrix B)
          Construct a sample without replacement of a matrix.
static RandomMatrix sampleWithReplacement(int m, int n, Matrix B)
          Construct a sample with replacement of a matrix.
 void setIsSample(boolean is)
          Specify if the RandomMatrix is a sample of an overall population, or if it's an overall population.
static RandomMatrix triangular(int m, int n, double min, double max)
          Construct an m-by-n matrix of random numbers from a symetric triangular random variable.
static RandomMatrix triangular(int m, int n, double min, double med, double max)
          Construct an m-by-n matrix of random numbers from a non-symetric triangular random variable.
static RandomMatrix uniform(int m, int n, double min, double max)
          Construct an m-by-n matrix of random numbers from a uniform random variable.
 AbstractMatrix variance()
          Generate a variance matrix, each column contains values of a pulling.
static RandomMatrix weibull(int m, int n, double lambda, double c)
          Construct an m-by-n matrix of random numbers from a Weibull random variable.
 
Methods inherited from class org.jmat.data.Matrix
diagonal, get, getInstance, identity, incrementColumns, incrementColumns, incrementRows, incrementRows, mergeColumns, mergeRows, random, reset, set
 
Methods inherited from class org.jmat.data.AbstractMatrix
cholesky, condition, copy, cumProduct, cumSum, deleteColumn, deleteColumns, deleteColumns, deleteRow, deleteRows, deleteRows, determinant, distance, divide, divide, divideEquals, ebeAbs, ebeAbsEquals, ebeCos, ebeCosEquals, ebeDivide, ebeDivideEquals, ebeExp, ebeExpEquals, ebeFunction, ebeFunctionEquals, ebeInverse, ebeInverseEquals, ebeLog, ebeLogEquals, ebePower, ebePower, ebePowerEquals, ebePowerEquals, ebeSin, ebeSinEquals, ebeSqrt, ebeSqrtEquals, ebeTimes, ebeTimesEquals, eig, find, find, fromASCIIFile, fromClipBoard, fromString, fromXMLElement, getColumn, getColumns, getColumns, getDiagonal, getDiagonal, getDoubleArrayCopy, getInstanceCopyOf, getRow, getRows, getRows, getSubMatrix, insertColumns, insertRows, inverse, lu, max, mergeColumns, mergeRows, min, minus, minus, minusEquals, minusEquals, norm1, norm2, normFrobenius, normInfinity, plus, plus, plusEquals, plusEquals, product, qr, rank, reshapeColumns, reshapeRows, resize, slice, slice, solve, sort, sum, svd, times, times, timesEquals, toASCIIFile, toClipBoard, toCommandLine, toHist2DPanel, toHist2DPanel, toHist3DPanel, toHist3DPanel, toPlot2DPanel, toPlot2DPanel, toPlot3DPanel, toPlot3DPanel, toString, toTablePanel, toXMLElement, trace, transpose, transposeEquals, uminus, uminusEquals
 
Methods inherited from class org.jmat.data.AbstractDoubleArray
checkColumnDimension, checkColumnDimension, checkDiagonal, checkDimensions, checkDimensions, checkRowDimension, checkRowDimension, checkSymetric, deleteColumnEquals, deleteColumnsEquals, deleteColumnsEquals, deleteRowEquals, deleteRowsEquals, deleteRowsEquals, getArrayCopy, getColumnArrayCopy, getColumnDimension, getRowArrayCopy, getRowDimension, insertColumnsEquals, insertRowsEquals, isDiagonal, isEqual, isSymetric, mergeColumnsEquals, mergeRowsEquals, putColumnIn, putColumnsIn, putColumnsIn, putDiagonalIn, putDiagonalIn, putRowIn, putRowsIn, putRowsIn, putSubMatrixIn, reshapeColumnsEquals, reshapeRowsEquals, resizeEquals, setAllConstant, setAllDiagonal, setAllIdentity, setAllIncrementColumns, setAllIncrementColumns, setAllIncrementRows, setAllIncrementRows, setAllMergeColumns, setAllMergeRows, setAllRandom, setColumn, setColumn, setColumns, setColumns, setRow, setRow, setRows, setRows, setSubMatrix, setSubMatrix, toDouble, toDouble2DArray, toDoubleArray, toDoubleColumnArray, toDoubleRowArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RandomMatrix

public RandomMatrix(int m,
                    int n)
Construct an m-by-n matrix of 0.

Parameters:
m - Number of rows.
n - Number of columns.

RandomMatrix

public RandomMatrix(AbstractMatrix M)
Construct an m-by-n matrix of 0.

Parameters:
M - Matrix to construct.
Method Detail

uniform

public static RandomMatrix uniform(int m,
                                   int n,
                                   double min,
                                   double max)
Construct an m-by-n matrix of random numbers from a uniform random variable.

Parameters:
m - Number of rows.
n - Number of columns.
min - Min of the random variable.
max - Max of the random variable.
Returns:
A RandomMatrix.

dirac

public static RandomMatrix dirac(int m,
                                 int n,
                                 AbstractMatrix val_prob)
Construct an m-by-n matrix of random numbers from a discrete random variable.

Parameters:
m - Number of rows.
n - Number of columns.
val_prob - Matrix of the discrete value and their probabilities.
Returns:
A RandomMatrix.

normal

public static RandomMatrix normal(int m,
                                  int n,
                                  double mu,
                                  double sigma)
Construct an m-by-n matrix of random numbers from a Gaussian (Normal) random variable.

Parameters:
m - Number of rows.
n - Number of columns.
mu - Mean of the random variable.
sigma - Standard deviation of the random variable.
Returns:
A RandomMatrix.

logNormal

public static RandomMatrix logNormal(int m,
                                     int n,
                                     double mu,
                                     double sigma)
Construct an m-by-n matrix of random numbers from a LogNormal random variable.

Parameters:
m - Number of rows.
n - Number of columns.
mu - Mean of the Normal random variable.
sigma - Standard deviation of the Normal random variable.
Returns:
A RandomMatrix.

exponential

public static RandomMatrix exponential(int m,
                                       int n,
                                       double lambda)
Construct an m-by-n matrix of random numbers from an exponantial random variable.

Parameters:
m - Number of rows.
n - Number of columns.
lambda - Parmaeter of the exponential random variable.
Returns:
A RandomMatrix.

triangular

public static RandomMatrix triangular(int m,
                                      int n,
                                      double min,
                                      double max)
Construct an m-by-n matrix of random numbers from a symetric triangular random variable.

Parameters:
m - Number of rows.
n - Number of columns.
min - Min of the random variable.
max - Max of the random variable.
Returns:
A RandomMatrix.

triangular

public static RandomMatrix triangular(int m,
                                      int n,
                                      double min,
                                      double med,
                                      double max)
Construct an m-by-n matrix of random numbers from a non-symetric triangular random variable.

Parameters:
m - Number of rows.
n - Number of columns.
min - Min of the random variable.
med - Value of the random variable with max density.
max - Max of the random variable.
Returns:
A RandomMatrix.

beta

public static RandomMatrix beta(int m,
                                int n,
                                double a,
                                double b)
Construct an m-by-n matrix of random numbers from a Beta random variable.

Parameters:
m - Number of rows.
n - Number of columns.
a - First parameter of the Beta random variable < 1.
b - Second parameter of the Beta random variable < 1.
Returns:
A RandomMatrix.

cauchy

public static RandomMatrix cauchy(int m,
                                  int n,
                                  double mu,
                                  double sigma)
Construct an m-by-n matrix of random numbers from a Cauchy random variable.

Parameters:
m - Number of rows.
n - Number of columns.
mu - Median of the Weibull random variable
sigma - Second parameter of the Cauchy random variable.
Returns:
A RandomMatrix.

weibull

public static RandomMatrix weibull(int m,
                                   int n,
                                   double lambda,
                                   double c)
Construct an m-by-n matrix of random numbers from a Weibull random variable.

Parameters:
m - Number of rows.
n - Number of columns.
lambda - First parameter of the Weibull random variable.
c - Second parameter of the Weibull random variable.
Returns:
A RandomMatrix.

rejection

public static RandomMatrix rejection(int m,
                                     int n,
                                     DoubleFunction fun,
                                     double min,
                                     double max)
Construct an m-by-n matrix of random numbers from a random variable definied by its density function, using the rejection technic. ! WARNING : this simulation technic can take a very long time !

Parameters:
m - Number of rows.
n - Number of columns.
fun - Density function of the random variable.
min - Min of the random variable.
max - Max of the random variable.
Returns:
A RandomMatrix.

sampleWithReplacement

public static RandomMatrix sampleWithReplacement(int m,
                                                 int n,
                                                 Matrix B)
Construct a sample with replacement of a matrix.

Parameters:
m - Number of rows.
n - Number of columns.
B - Matrix to sample.
Returns:
A RandomMatrix.

sampleWithoutReplacement

public static RandomMatrix sampleWithoutReplacement(int m,
                                                    int n,
                                                    Matrix B)
Construct a sample without replacement of a matrix.

Parameters:
m - Number of rows.
n - Number of columns.
B - Matrix to sample.
Returns:
A RandomMatrix.

setIsSample

public void setIsSample(boolean is)
Specify if the RandomMatrix is a sample of an overall population, or if it's an overall population. This information is needed to calculate unbiaised estimtors of variance for instance.

Parameters:
is - Is sample?.

getIsSample

public boolean getIsSample()
Specify if the RandomMatrix is a sample of an overall population, or if it's an overall population. This information is needed to calculate unbiaised estimtors of variance for instance.

Returns:
is Sample?

mean

public AbstractMatrix mean()
Generate a row matrix, each column contents the mean value of the columns.

Overrides:
mean in class AbstractMatrix
Returns:
An 1-by-n matrix.

covariance

public AbstractMatrix covariance()
Generate a covariance matrix, each column contains values of a pulling.

Overrides:
covariance in class AbstractMatrix
Returns:
An n-by-n matrix.

correlation

public AbstractMatrix correlation()
Generate a correlation matrix, each column contains values of a pulling.

Overrides:
correlation in class AbstractMatrix
Returns:
An n-by-n matrix.

variance

public AbstractMatrix variance()
Generate a variance matrix, each column contains values of a pulling.

Overrides:
variance in class AbstractMatrix
Returns:
An 1-by-n matrix.