ShiftedExponentialRV.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 2001, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** Reliability module developed by:                                   **
00020 **   Terje Haukaas (haukaas@ce.berkeley.edu)                          **
00021 **   Armen Der Kiureghian (adk@ce.berkeley.edu)                       **
00022 **                                                                    **
00023 ** ****************************************************************** */
00024                                                                         
00025 // $Revision: 1.6 $
00026 // $Date: 2003/03/04 00:44:35 $
00027 // $Source: /usr/local/cvs/OpenSees/SRC/reliability/domain/distributions/ShiftedExponentialRV.cpp,v $
00028 
00029 
00030 //
00031 // Written by Terje Haukaas (haukaas@ce.berkeley.edu) 
00032 //
00033 
00034 #include <ShiftedExponentialRV.h>
00035 #include <math.h>
00036 #include <string.h>
00037 #include <classTags.h>
00038 #include <OPS_Globals.h>
00039 
00040 ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, 
00041                  double passedMean,
00042                  double passedStdv,
00043                  double passedStartValue)
00044 :RandomVariable(passedTag, RANDOM_VARIABLE_shiftedexponential)
00045 {
00046         tag = passedTag ;
00047         lambda = 1/passedStdv;
00048         x0 = passedMean - passedStdv;
00049         startValue = passedStartValue;
00050 }
00051 ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, 
00052                  double passedParameter1,
00053                  double passedParameter2,
00054                  double passedParameter3,
00055                  double passedParameter4,
00056                  double passedStartValue)
00057 :RandomVariable(passedTag, RANDOM_VARIABLE_shiftedexponential)
00058 {
00059         tag = passedTag ;
00060         lambda = passedParameter1;
00061         x0 = passedParameter2;
00062         startValue = passedStartValue;
00063 }
00064 ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, 
00065                  double passedMean,
00066                  double passedStdv)
00067 :RandomVariable(passedTag, RANDOM_VARIABLE_shiftedexponential)
00068 {
00069         tag = passedTag ;
00070         lambda = 1/passedStdv;
00071         x0 = passedMean - passedStdv;
00072         startValue = getMean();
00073 }
00074 ShiftedExponentialRV::ShiftedExponentialRV(int passedTag, 
00075                  double passedParameter1,
00076                  double passedParameter2,
00077                  double passedParameter3,
00078                  double passedParameter4)
00079 :RandomVariable(passedTag, RANDOM_VARIABLE_shiftedexponential)
00080 {
00081         tag = passedTag ;
00082         lambda = passedParameter1;
00083         x0 = passedParameter2;
00084         startValue = getMean();
00085 }
00086 
00087 
00088 ShiftedExponentialRV::~ShiftedExponentialRV()
00089 {
00090 }
00091 
00092 
00093 void
00094 ShiftedExponentialRV::Print(OPS_Stream &s, int flag)
00095 {
00096 }
00097 
00098 
00099 double
00100 ShiftedExponentialRV::getPDFvalue(double rvValue)
00101 {
00102         double result;
00103         if ( x0 < rvValue ) {
00104                 result = lambda * exp(-lambda * (rvValue-x0));
00105         }
00106         else {
00107                 result = 0.0;
00108         }
00109         return result;
00110 }
00111 
00112 
00113 double
00114 ShiftedExponentialRV::getCDFvalue(double rvValue)
00115 {
00116         double result;
00117         if ( x0 < rvValue ) {
00118                 result = 1 - exp(-lambda*(rvValue-x0));
00119         }
00120         else {
00121                 result = 0.0;
00122         }
00123         return result;
00124 }
00125 
00126 
00127 double
00128 ShiftedExponentialRV::getInverseCDFvalue(double probValue)
00129 {
00130         return x0 - (log(1.0-probValue)) / lambda;
00131 }
00132 
00133 
00134 const char *
00135 ShiftedExponentialRV::getType()
00136 {
00137         return "SHIFTEDEXPONENTIAL";
00138 }
00139 
00140 
00141 double 
00142 ShiftedExponentialRV::getMean()
00143 {
00144         return x0 + 1/lambda;
00145 }
00146 
00147 
00148 
00149 double 
00150 ShiftedExponentialRV::getStdv()
00151 {
00152         return 1/lambda;
00153 }
00154 
00155 
00156 double 
00157 ShiftedExponentialRV::getStartValue()
00158 {
00159         return startValue;
00160 }
00161 
00162 double ShiftedExponentialRV::getParameter1()  {return lambda;}
00163 double ShiftedExponentialRV::getParameter2()  {return x0;}
00164 double ShiftedExponentialRV::getParameter3()  {opserr<<"No such parameter in r.v. #"<<tag<<endln; return 0.0;}
00165 double ShiftedExponentialRV::getParameter4()  {opserr<<"No such parameter in r.v. #"<<tag<<endln; return 0.0;}

Generated on Mon Oct 23 15:05:26 2006 for OpenSees by doxygen 1.5.0