Rev 414 | Rev 1334 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 291 | mhscott | 1 | /* ****************************************************************** ** |
| 2 | ** OpenSees - Open System for Earthquake Engineering Simulation ** |
||
| 3 | ** Pacific Earthquake Engineering Research Center ** |
||
| 4 | ** ** |
||
| 5 | ** ** |
||
| 6 | ** (C) Copyright 2001, The Regents of the University of California ** |
||
| 7 | ** All Rights Reserved. ** |
||
| 8 | ** ** |
||
| 9 | ** Commercial use of this program without express permission of the ** |
||
| 10 | ** University of California, Berkeley, is strictly prohibited. See ** |
||
| 11 | ** file 'COPYRIGHT' in main directory for information on usage and ** |
||
| 12 | ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. ** |
||
| 13 | ** ** |
||
| 14 | ** Developed by: ** |
||
| 15 | ** Frank McKenna (fmckenna@ce.berkeley.edu) ** |
||
| 16 | ** Gregory L. Fenves (fenves@ce.berkeley.edu) ** |
||
| 17 | ** Filip C. Filippou (filippou@ce.berkeley.edu) ** |
||
| 18 | ** ** |
||
| 19 | ** Reliability module developed by: ** |
||
| 20 | ** Terje Haukaas (haukaas@ce.berkeley.edu) ** |
||
| 21 | ** Armen Der Kiureghian (adk@ce.berkeley.edu) ** |
||
| 22 | ** ** |
||
| 23 | ** ****************************************************************** */ |
||
| 24 | |||
| 1271 | fmk | 25 | // $Revision: 1.5 $ |
| 26 | // $Date: 2003-02-14 23:01:55 $ |
||
| 291 | mhscott | 27 | // $Source: /usr/local/cvs/OpenSees/SRC/reliability/domain/distributions/ShiftedExponentialRV.cpp,v $ |
| 28 | |||
| 29 | |||
| 30 | // |
||
| 31 | // Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000 |
||
| 32 | // Revised: haukaas 06/00 (core code) |
||
| 33 | // haukaas 06/01 (made part of official OpenSees) |
||
| 34 | // |
||
| 35 | |||
| 36 | #include <ShiftedExponentialRV.h> |
||
| 37 | #include <math.h> |
||
| 38 | #include <string.h> |
||
| 1271 | fmk | 39 | #include <OPS_Globals.h> |
| 291 | mhscott | 40 | |
| 41 | ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, |
||
| 42 | double passedMean, |
||
| 43 | double passedStdv, |
||
| 44 | double passedStartValue) |
||
| 45 | :RandomVariable(passedTag, passedMean, passedStdv, passedStartValue) |
||
| 46 | { |
||
| 47 | tag = passedTag ; |
||
| 48 | lambda = 1/passedStdv; |
||
| 49 | x0 = passedMean - passedStdv; |
||
| 50 | startValue = passedStartValue; |
||
| 51 | } |
||
| 52 | ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, |
||
| 53 | double passedParameter1, |
||
| 54 | double passedParameter2, |
||
| 55 | double passedParameter3, |
||
| 56 | double passedParameter4, |
||
| 57 | double passedStartValue) |
||
| 58 | :RandomVariable(passedTag, passedParameter1, passedParameter2, passedParameter3, passedParameter4, passedStartValue) |
||
| 59 | { |
||
| 60 | tag = passedTag ; |
||
| 61 | lambda = passedParameter1; |
||
| 62 | x0 = passedParameter2; |
||
| 63 | startValue = passedStartValue; |
||
| 64 | } |
||
| 65 | ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, |
||
| 66 | double passedMean, |
||
| 67 | double passedStdv) |
||
| 68 | :RandomVariable(passedTag, passedMean, passedStdv) |
||
| 69 | { |
||
| 70 | tag = passedTag ; |
||
| 71 | lambda = 1/passedStdv; |
||
| 72 | x0 = passedMean - passedStdv; |
||
| 73 | startValue = getMean(); |
||
| 74 | } |
||
| 75 | ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, |
||
| 76 | double passedParameter1, |
||
| 77 | double passedParameter2, |
||
| 78 | double passedParameter3, |
||
| 79 | double passedParameter4) |
||
| 80 | :RandomVariable(passedTag, passedParameter1, passedParameter2, passedParameter3, passedParameter4) |
||
| 81 | { |
||
| 82 | tag = passedTag ; |
||
| 83 | lambda = passedParameter1; |
||
| 84 | x0 = passedParameter2; |
||
| 85 | startValue = getMean(); |
||
| 86 | } |
||
| 87 | |||
| 88 | |||
| 89 | ShiftedExponentialRV::~ShiftedExponentialRV() |
||
| 90 | { |
||
| 91 | } |
||
| 92 | |||
| 93 | |||
| 94 | void |
||
| 1271 | fmk | 95 | ShiftedExponentialRV::Print(OPS_Stream &s, int flag) |
| 291 | mhscott | 96 | { |
| 97 | } |
||
| 98 | |||
| 99 | |||
| 100 | double |
||
| 101 | ShiftedExponentialRV::getPDFvalue(double rvValue) |
||
| 102 | { |
||
| 103 | double result; |
||
| 104 | if ( x0 < rvValue ) { |
||
| 105 | result = lambda * exp(-lambda * (rvValue-x0)); |
||
| 106 | } |
||
| 107 | else { |
||
| 108 | result = 0.0; |
||
| 109 | } |
||
| 110 | return result; |
||
| 111 | } |
||
| 112 | |||
| 113 | |||
| 114 | double |
||
| 115 | ShiftedExponentialRV::getCDFvalue(double rvValue) |
||
| 116 | { |
||
| 117 | double result; |
||
| 118 | if ( x0 < rvValue ) { |
||
| 119 | result = 1 - exp(-lambda*(rvValue-x0)); |
||
| 120 | } |
||
| 121 | else { |
||
| 122 | result = 0.0; |
||
| 123 | } |
||
| 124 | return result; |
||
| 125 | } |
||
| 126 | |||
| 127 | |||
| 128 | double |
||
| 129 | ShiftedExponentialRV::getInverseCDFvalue(double probValue) |
||
| 130 | { |
||
| 131 | return x0 - (log(1.0-probValue)) / lambda; |
||
| 132 | } |
||
| 133 | |||
| 134 | |||
| 414 | mhscott | 135 | const char * |
| 291 | mhscott | 136 | ShiftedExponentialRV::getType() |
| 137 | { |
||
| 414 | mhscott | 138 | return "SHIFTEDEXPONENTIAL"; |
| 291 | mhscott | 139 | } |
| 140 | |||
| 141 | |||
| 142 | double |
||
| 143 | ShiftedExponentialRV::getMean() |
||
| 144 | { |
||
| 145 | return x0 + 1/lambda; |
||
| 146 | } |
||
| 147 | |||
| 148 | |||
| 149 | |||
| 150 | double |
||
| 151 | ShiftedExponentialRV::getStdv() |
||
| 152 | { |
||
| 153 | return 1/lambda; |
||
| 154 | } |
||
| 155 | |||
| 156 | |||
| 157 | double |
||
| 158 | ShiftedExponentialRV::getStartValue() |
||
| 159 | { |
||
| 160 | return startValue; |
||
| 161 | } |
||
| 162 | |||
| 163 | double ShiftedExponentialRV::getParameter1() {return lambda;} |
||
| 164 | double ShiftedExponentialRV::getParameter2() {return x0;} |
||
| 1271 | fmk | 165 | double ShiftedExponentialRV::getParameter3() {opserr<<"No such parameter in r.v. #"<<tag<<endln; return 0.0;} |
| 166 | double ShiftedExponentialRV::getParameter4() {opserr<<"No such parameter in r.v. #"<<tag<<endln; return 0.0;} |