| 191 | } |
| 192 | |
| 193 | double |
| 194 | IPCM::IPCMfunc(const Vector &allbeta, const Matrix &rhoin, double modifier) |
| 195 | { |
| 196 | int n = allbeta.Size(); |
| 197 | static NormalRV uRV(1, 0.0, 1.0); |
| 198 | Vector beta(n); |
| 199 | Matrix rho(n,n); |
| 200 | int i,ic,ir,j,k; |
| 201 | |
| 202 | double c1, c2, r, a, b, c21, jprob; |
| 203 | double orig, newg, modval; |
| 204 | CorrelatedStandardNormal phi2(0.0); |
| 205 | |
| 206 | rho = rhoin; |
| 207 | for (i=0; i < n; i++) { |
| 208 | beta(i) = allbeta(i)*modifier; |
| 209 | rho(i,i) = beta(i); |
| 210 | } |
| 211 | |
| 212 | if (n == 1) |
| 213 | return 1.0 - uRV.getCDFvalue( beta(0) ); |
| 214 | else if (n == 2) { |
| 215 | // check closed-form solution |
| 216 | phi2.setCorrelation(rhoin(1,0)); |
| 217 | double pcf = phi2.getCDF(beta(0),beta(1)); |
| 218 | //opserr << "pcf = " << pcf << " and PCM = " << exp(pf) << endln; |
| 219 | return 1.0 - pcf; |
| 220 | } else { |
| 221 | |
| 222 | // ���� FIRST CYCLE ���������������� |
| 223 | double pdfc1 = uRV.getPDFvalue(rho(1-1,1-1)); |
| 224 | double cdfc1 = uRV.getCDFvalue(rho(1-1,1-1)); |
| 225 | double A1 = pdfc1/cdfc1; |
| 226 | double B1 = A1*(rho(1-1,1-1) + A1); |
| 227 | for (k = 2; k <= n; k++) { |
| 228 | c1 = -rho(1-1,1-1); |
| 229 | c2 = -rho(k-1,k-1); |
| 230 | r = rho(1-1,k-1); |
| 231 | a = pdfc1/(1.0 - cdfc1); |
| 232 | b = a*(c1 + a); |
| 233 | c21 = (c2 + r*a)/sqrt(1.0 - r*r*b); |
| 234 | |
| 235 | // original |
| 236 | orig = (1.0 - cdfc1)*uRV.getCDFvalue(c21); |
| 237 | // bootstrap with binormal |
| 238 | phi2.setCorrelation(r); |
| 239 | newg = phi2.getCDF(c1,c2); |
| 240 | |
| 241 | jprob = uRV.getCDFvalue(c2) - newg; |
| 242 | // might have a div by 0 problem here |
| 243 | modval = 1.0 - jprob/cdfc1; |
| 244 | if ( isnan(modval) ) { |
| 245 | opserr << "SystemAnalysis::IPCM WARNING illegal norminv value input (nan): " |
| 246 | << "cdfc1 = " << cdfc1 << " and c2 = " << c2 << endln; |
| 247 | } |
| 248 | |
| 249 | rho(k-1,1-1) = uRV.getInverseCDFvalue(modval); |
| 250 | } |
nothing calls this directly
no test coverage detected