#include <abkrand.h>
Collaboration diagram for RandomNormCorrTuplesT< RK >:
Public Member Functions | |
RandomNormCorrTuplesT (const vector< double > &means, const vector< double > &stdDevs, const vector< vector< double > > &corrs, const char *locIdent, unsigned counterOverride=UINT_MAX, Verbosity verb=Verbosity("silent")) | |
~RandomNormCorrTuplesT () | |
void | getTuple (vector< double > &tuple) |
bool | bad () const |
Private Member Functions | |
bool | _findBasis (const vector< vector< double > > &_rho_ij, vector< vector< double > > &_v_ij) |
Private Attributes | |
const unsigned | _n |
vector< RandomNormalT< RK > * > | _norm_j |
vector< double > | _y_j |
const vector< double > | _mu_i |
const vector< double > | _sigma_i |
vector< vector< double > > | _v_ij |
bool | _bad |
|
|
|
Definition at line 147 of file abkrand_templ.cxx. References RandomNormCorrTuplesT< RK >::_norm_j.
|
|
Definition at line 107 of file abkrand_templ.cxx.
00109 { 00110 _v_ij.clear(); 00111 const unsigned n=_rho_ij.size()+1; 00112 vector<double> zeros(n,0); 00113 _v_ij.insert(_v_ij.end(),n,zeros); 00114 _v_ij[0][0]=1; 00115 unsigned i,j,k; 00116 for (i=1;i<n;i++) 00117 { 00118 double sumsq=0; 00119 for (j=0;j<i;j++) 00120 { 00121 // dot product of v_i with v_j = rho_ij, that 00122 // is _rho_ij[j][i-j-i] 00123 double val=_rho_ij[j][i-j-1]; 00124 for (k=0;k<j;k++) 00125 { 00126 val -= _v_ij[i][k]*_v_ij[j][k]; 00127 } 00128 val /= _v_ij[j][j]; 00129 00130 _v_ij[i][j]=val; 00131 sumsq += val*val; 00132 } 00133 00134 if (sumsq >= 1) return false; //If sumsq>1, can't get new 00135 //length-1 vector with correct 00136 //correlations; if sumsq==1, could, 00137 //but vecs would be lin. dep. 00138 00139 _v_ij[i][i] = sqrt(1-sumsq); //make vector have length 1 00140 00141 } 00142 00143 return true; 00144 } |
|
Definition at line 545 of file abkrand.h. References RandomNormCorrTuplesT< RK >::_bad.
00545 {return _bad;} |
|
Definition at line 195 of file abkrand_templ.cxx. References RandomNormCorrTuplesT< RK >::_bad, RandomNormCorrTuplesT< RK >::_mu_i, RandomNormCorrTuplesT< RK >::_n, RandomNormCorrTuplesT< RK >::_norm_j, RandomNormCorrTuplesT< RK >::_sigma_i, RandomNormCorrTuplesT< RK >::_v_ij, RandomNormCorrTuplesT< RK >::_y_j, and abkfatal.
00196 { 00197 abkfatal(tuple.size()==_n,"Bad tuple size"); 00198 abkfatal(!_bad,"Attempt to get tuple from bad RNG"); 00199 unsigned i,j; 00200 for (j=0;j<_n;j++) 00201 _y_j[j]=_norm_j[j]->operator double(); 00202 00203 for (i=0;i<_n;i++) 00204 { 00205 double val=0; 00206 const vector<double> &v_i=_v_ij[i]; 00207 for (j=0;j<=i;j++) 00208 val += v_i[j]*_y_j[j]; 00209 val *= _sigma_i[i]; 00210 val += _mu_i[i]; 00211 tuple[i]=val; 00212 } 00213 } |
|
Definition at line 527 of file abkrand.h. Referenced by RandomNormCorrTuplesT< RK >::bad(), and RandomNormCorrTuplesT< RK >::getTuple(). |
|
Definition at line 523 of file abkrand.h. Referenced by RandomNormCorrTuplesT< RK >::getTuple(). |
|
Definition at line 519 of file abkrand.h. Referenced by RandomNormCorrTuplesT< RK >::getTuple(). |
|
Definition at line 520 of file abkrand.h. Referenced by RandomNormCorrTuplesT< RK >::getTuple(), and RandomNormCorrTuplesT< RK >::~RandomNormCorrTuplesT(). |
|
Definition at line 524 of file abkrand.h. Referenced by RandomNormCorrTuplesT< RK >::getTuple(). |
|
Definition at line 525 of file abkrand.h. Referenced by RandomNormCorrTuplesT< RK >::getTuple(). |
|
Definition at line 521 of file abkrand.h. Referenced by RandomNormCorrTuplesT< RK >::getTuple(). |