## Statistics Class RandomVector

```java.lang.Object Statistics.RandomVector
```
Direct Known Subclasses:
LiborVector

public abstract class RandomVector
extends java.lang.Object

This class is the vectorial analogue of the class `RandomVariable` and implements componentwise expectations and standard deviations as well as covariations and correlations between components.

Only a small subset of the functionality of the class `RandomVariable` is extended to vectors. Missing functionality can often be accessed by reducing the random vector to the collection of its components defined as random variables.

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

The main difference between a random vector and a collection of separate random variables is the fact that for a random vector one and the same call to the underlying stochastic generator sets the values of all components. This allows us to implement correlated random variables. By contrast, two separate calls

x1=X.getValue(); x2=X.getValue();

for the same random variable X simulate independent versions X1, X2 of the random variable X.

Information: Random vectors X are often observed in a context with increasing information becoming available about X as time t passes. Clearly one will sample 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.

 Constructor Summary `RandomVector(int d)`

 Method Summary ` double` ```conditionalCorrelation(int i, int j, int t, int N)```           Correlation Corr(X_i,X_j) computed from a sample of size N and conditioned on information available at time t. ` double` ```conditionalCovariance(int i, int j, int t, int N)```           Covariance Cov(X_i,X_j) computed from a sample of size N and conditioned on information available at time t. ` double[][]` ```conditionalCovarianceMatrix(int t, int N)```           Covariance matrix `(Cov(X_i,X_j))_{i,j=0}^{dim-1}` computed from a sample of size N and conditioned on information available at time t. ` double[]` ```conditionalExpectation(int t, int N)```           Expectation of X conditioned on information available at time t and computed from a sample of size N. ` double[]` ```conditionalExpectation(int t, int N, int m, javax.swing.JProgressBar jPrgBar)```           Same as `conditionalExpectation(int,int)` with computational progress reported to a progress bar. ` double[][]` ```conditionalMeanAndStandardDeviation(int t, int N)```           Returns the vector of component means (return_value) and the vector of component standard deviations (return_value) conditioned on information available at time t and computed from a sample of size N. ` double[][]` ```conditionalMeanAndStandardDeviation(int t, int N, int sampleGroupSize)```           The vector of means (return_value) of the components of the random vector X and the vector of standard deviations (return_value) of the sample group means of the components of X conditioned on information available at time t. ` double[][]` ```conditionalMeanAndStandardDeviation(int t, int N, int m, int sampleGroupSize, javax.swing.JProgressBar jPrgBar)```           Same as `conditionalMeanAndStandardDeviation(int,int,int)` computational progress is reported to a progress bar. ` double[][]` ```conditionalMeanAndStandardDeviation(int t, int N, int m, javax.swing.JProgressBar jPrgBar)```           Same as `conditionalMeanAndStandardDeviation(int,int)` with computational progress reported to a progress bar. ` double` ```correlation(int i, int j, int N)```           Unconditional version of `conditionalCorrelation(int,int,int,int)`. ` double` ```covariance(int i, int j, int N)```           Unconditional version of `conditionalCovariance(int,int,int,int)`. ` double[][]` `covarianceMatrix(int N)`           The unconditional covariance matrix, ie. ` int` `dim()`           Dimension. ` double[]` `expectation(int N)`           Unconditional version of `conditionalExpectation(int,int)`. ` double[]` ```expectation(int N, int m, javax.swing.JProgressBar jPrgBar)```           Unconditional version of `conditionalExpectation(int,int,int,JProgressBar)`. `abstract  double[]` `getValue(int t)`           The next random sample conditioned on information available at time t. `static void` `main(java.lang.String[] args)`           Tests the expectation of a random vector of dimension 3 where component j is the sum of j+1 independent standard normal random variables. ` double[][]` `meanAndStandardDeviation(int N)`           Unconditional version of `conditionalMeanAndStandardDeviation(int, int)`. ` double[][]` ```meanAndStandardDeviation(int N, int sampleGroupSize)```           Unconditional version of `conditionalMeanAndStandardDeviation(int,int,int)`. ` double[][]` ```meanAndStandardDeviation(int N, int m, int sampleGroupSize, javax.swing.JProgressBar jPrgBar)```           Unconditional version of `(int,int,int,int,JProgressBar)`. ` double[][]` ```meanAndStandardDeviation(int N, int m, javax.swing.JProgressBar jPrgBar)```           Unconditional version of `conditionalMeanAndStandardDeviation(int,int,int,JProgressBar)`.

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Constructor Detail

### RandomVector

`public RandomVector(int d)`
Parameters:
`d` - Dimension of the random vector.
 Method Detail

### dim

`public int dim()`
Dimension.

### getValue

`public abstract double[] getValue(int t)`
The next random sample conditioned on information available at time t.

### conditionalExpectation

```public double[] conditionalExpectation(int t,
int N)```

Expectation of X conditioned on information available at time t and computed from a sample of size N. The mean is the vector of component means returned as an array double[dim].

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

### expectation

`public double[] expectation(int N)`

Unconditional version of `conditionalExpectation(int,int)`.

Parameters:
`N` - sample size.

### conditionalMeanAndStandardDeviation

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

Returns the vector of component means (return_value) and the vector of component standard deviations (return_value) conditioned on information available at time t and computed from a sample of size N.

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

### meanAndStandardDeviation

`public double[][] meanAndStandardDeviation(int N)`

Unconditional version of `conditionalMeanAndStandardDeviation(int, int)`.

Parameters:
`N` - Sample size.

### conditionalMeanAndStandardDeviation

```public double[][] conditionalMeanAndStandardDeviation(int t,
int N,
int sampleGroupSize)```
The vector of means (return_value) of the components of the random vector X and the vector of standard deviations (return_value) of the sample group means of the components of X conditioned on information available at time t.

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 deviations of the sample group means (in each component of X) and not the standard deviations of the components of X themselves. These standard deviations control confidence intervals for the component means of X computed as a mean of sample group means.

The number of sample groups simulated is [N/sampleGroupSize], where [x] denotes the greatest integer <= x. Consequently the number of samples generated is given by

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

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

### meanAndStandardDeviation

```public double[][] meanAndStandardDeviation(int N,
int sampleGroupSize)```

Unconditional version of `conditionalMeanAndStandardDeviation(int,int,int)`.

Parameters:
`N` - Sample size.

### conditionalExpectation

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

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

Parameters:
`t` - Current time (determines available information).
`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)```

Unconditional version of `conditionalExpectation(int,int,int,JProgressBar)`.

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,
javax.swing.JProgressBar jPrgBar)```

Same as `conditionalMeanAndStandardDeviation(int,int)` 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)```

Unconditional version of `conditionalMeanAndStandardDeviation(int,int,int,JProgressBar)`.

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)` computational progress is 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)```

Unconditional version of `(int,int,int,int,JProgressBar)`.

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

### conditionalCovariance

```public double conditionalCovariance(int i,
int j,
int t,
int N)```

Covariance Cov(X_i,X_j) computed from a sample of size N and conditioned on information available at time t.

Recall that Cov(X_i,X_j)=E(X_iX_j)-E(X_i)E(X_j).

Parameters:
`i` - Index of X-component.
`j` - Index of X-component.
`t` - Current time (determines information to condition on).
`N` - Size of sample used to estimate the covariation.

### covariance

```public double covariance(int i,
int j,
int N)```

Unconditional version of `conditionalCovariance(int,int,int,int)`.

Parameters:
`i` - Index of X-component.
`j` - Index of X-component.
`N` - Size of sample used to estimate the covariation.

### conditionalCovarianceMatrix

```public double[][] conditionalCovarianceMatrix(int t,
int N)```

Covariance matrix `(Cov(X_i,X_j))_{i,j=0}^{dim-1}` computed from a sample of size N and conditioned on information available at time t.

Recall that Cov(X_i,X_j)=E(X_iX_j)-E(X_i)E(X_j).

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

### covarianceMatrix

`public double[][] covarianceMatrix(int N)`

The unconditional covariance matrix, ie. the `conditionalCovarianceMatrix(t,N)` at `t=0`, no information to condition on.

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

### conditionalCorrelation

```public double conditionalCorrelation(int i,
int j,
int t,
int N)```

Correlation Corr(X_i,X_j) computed from a sample of size N and conditioned on information available at time t.

Recall that Corr(X,Y)=Cov(X,Y)/sqrt(Var(X))sqrt(Var(Y)) However efficieny calls for a different implementation.

Parameters:
`i` - index of X-component.
`j` - index of X-component.
`t` - Current time (determines information to condition on).
`N` - Size of sample used to estimate the correlation.

### correlation

```public double correlation(int i,
int j,
int N)```

Unconditional version of `conditionalCorrelation(int,int,int,int)`.

Parameters:
`i` - Index of X-component.
`j` - Index of X-component.
`N` - Size of sample used to estimate the correlation.

### main

`public static void main(java.lang.String[] args)`

Tests the expectation of a random vector of dimension 3 where component j is the sum of j+1 independent standard normal random variables.