MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / PCMfunc

Method PCMfunc

SRC/reliability/analysis/analysis/system/PCM.cpp:190–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190double
191PCM::PCMfunc(const Vector &allbeta, const Matrix &rhoin, double modifier)
192{
193 int n = allbeta.Size();
194 static NormalRV uRV(1, 0.0, 1.0);
195 Vector beta(n);
196 Matrix rho(n,n);
197 int i,ic,ir,j,k;
198
199 rho = rhoin;
200 for (i=0; i < n; i++) {
201 beta(i) = allbeta(i)*modifier;
202 rho(i,i) = beta(i);
203 }
204
205 if (n == 1)
206 return uRV.getCDFvalue( beta(0) );
207 else if (n == 2) {
208 // check closed-form solution
209 CorrelatedStandardNormal phi2(rhoin(1,0));
210 double pcf = phi2.getCDF(beta(0),beta(1));
211 //opserr << "pcf = " << pcf << " and PCM = " << exp(pf) << endln;
212 return pcf;
213 } else {
214
215 // ���� FIRST CYCLE ����������������
216 double A1 = uRV.getPDFvalue(rho(1-1,1-1))/(uRV.getCDFvalue(rho(1-1,1-1)));
217 double B1 = A1*(rho(1-1,1-1) + A1);
218 for (k = 2; k <= n; k++)
219 rho(k-1,1-1) = (rho(k-1,k-1) + rho(1-1,k-1)*A1)/sqrt(1 - rho(1-1,k-1)*rho(1-1,k-1)*B1);
220
221 for (ir = 2; ir <= n - 1; ir++) {
222 for (ic = ir + 1; ic <= n; ic++)
223 rho(ir-1,ic-1) = (rho(ir-1,ic-1) - rho(1-1,ir-1)*rho(1-1,ic-1)*B1)/sqrt((1-rho(1-1,ir-1)*rho(1-1,ir-1)*B1)*(1 - rho(1-1,ic-1)*rho(1-1,ic-1)*B1));
224 }
225
226 // ����- OTHER CYCLES ����������������
227 for (j = 2; j <= n - 1; j++) {
228 A1 = uRV.getPDFvalue(rho(j-1,j-2))/(uRV.getCDFvalue(rho(j-1,j-2)));
229 B1 = A1*(rho(j-1,j-2) + A1);
230 for (k = j + 1; k <= n; k++)
231 rho(k-1,j-1) = (rho(k-1,j-2) + rho(j-1,k-1)*A1)/sqrt(1 - rho(j-1,k-1)*rho(j-1,k-1)*B1);
232
233 for (ir = j + 1; ir <= n - 1; ir++) {
234 for (ic = ir + 1; ic <= n; ic++)
235 rho(ir-1,ic-1) = (rho(ir-1,ic-1) - rho(j-1,ir-1)*rho(j-1,ic-1)*B1)/sqrt((1 - rho(j-1,ir-1)*rho(j-1,ir-1)*B1)*(1 - rho(j-1,ic-1)*rho(j-1,ic-1)*B1));
236 }
237 }
238
239 // ���� Calculate the product of conditional marginals
240 double pf = log(uRV.getCDFvalue(rho(1-1,1-1)));
241 for (i = 2; i<=n; i++)
242 pf = pf + log(uRV.getCDFvalue(rho(i-1,i-2)));
243
244 return exp(pf);
245 }
246}

Callers

nothing calls this directly

Calls 4

getCDFMethod · 0.80
SizeMethod · 0.45
getCDFvalueMethod · 0.45
getPDFvalueMethod · 0.45

Tested by

no test coverage detected