org.lcsim.util
Class ArraySmearer

java.lang.Object
  extended byorg.lcsim.util.ArraySmearer

public class ArraySmearer
extends java.lang.Object

This class smears a vector of quantities in accordance with a multivariate normal distribution. The constructor takes a covariance matrix as input; only a minimal amount of checking is done. The method 'smear' takes an array and smears its members according to a gaussian distribution, whose width corresponds to the square root of the diagonal element of the covariance matrix. Here is an example of how the covariance terms are handled: v11 cov = v12 v22 v13 v23 v33 x1 = x1 + a1*rn1 x2 = x2 + a2*rn1 + b2*rn2 x3 = x3 + a3*rn1 + b3*rn2 + c3*rn3 where rn1, rn2 and rn3 are independently generated normal random numbers a1 = sqrt(v11) if a1 = 0, then a2 = a3 = 0 otherwise a2 = v12/a1, a3 = v13/a1 b2 = sqrt(v22 - a2*a2) if b2 = 0, then b3 = 0 otherwise b3 = (v23 - a2*a3)/b2 c3 = sqrt(v33 - a3*a3 - b3*b3)

Author:
Norman A. Graf

Constructor Summary
ArraySmearer(double[][] cov)
          constructor from the covariance matrix
 
Method Summary
 void generate(double[] vec)
          Generate a vector of variables distributed according to the covariance matrix.
 void smear(double[] vec)
          Smear a vector according to the covariance matrix.
 java.lang.String toString()
          Output Stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArraySmearer

public ArraySmearer(double[][] cov)
constructor from the covariance matrix

Parameters:
cov - The covariance matrix as
Method Detail

smear

public void smear(double[] vec)
Smear a vector according to the covariance matrix. Note overwrite of input argument!

Parameters:
vec - The array to be smeared.

generate

public void generate(double[] vec)
Generate a vector of variables distributed according to the covariance matrix.

Parameters:
vec - Array to be filled

toString

public java.lang.String toString()
Output Stream

Returns:
String representation of object