ExponentialRV.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:33 $
00027 // $Source: /usr/local/cvs/OpenSees/SRC/reliability/domain/distributions/ExponentialRV.cpp,v $
00028 
00029 
00030 //
00031 // Written by Terje Haukaas (haukaas@ce.berkeley.edu) 
00032 //
00033 
00034 #include <ExponentialRV.h>
00035 #include <math.h>
00036 #include <string.h>
00037 #include <classTags.h>
00038 #include <OPS_Globals.h>
00039 
00040 ExponentialRV::ExponentialRV(int passedTag, 
00041                  double passedMean,
00042                  double passedStdv,
00043                  double passedStartValue)
00044 :RandomVariable(passedTag, RANDOM_VARIABLE_exponential)
00045 {
00046         // Note: this constructor is void.
00047         opserr << "WARNING: This type of random variable is not uniquely defined by mean and stdv." << endln;
00048 }
00049 ExponentialRV::ExponentialRV(int passedTag, 
00050                  double passedParameter1,
00051                  double passedParameter2,
00052                  double passedParameter3,
00053                  double passedParameter4,
00054                  double passedStartValue)
00055 :RandomVariable(passedTag, RANDOM_VARIABLE_exponential)
00056 {
00057         tag = passedTag ;
00058         lambda = passedParameter1;
00059         startValue = passedStartValue;
00060 }
00061 ExponentialRV::ExponentialRV(int passedTag, 
00062                  double passedMean,
00063                  double passedStdv)
00064 :RandomVariable(passedTag, RANDOM_VARIABLE_exponential)
00065 {
00066         // Note: this constructor is void.
00067         opserr << "WARNING: This type of random variable is not uniquely defined by mean and stdv." << endln;
00068 }
00069 ExponentialRV::ExponentialRV(int passedTag, 
00070                  double passedParameter1,
00071                  double passedParameter2,
00072                  double passedParameter3,
00073                  double passedParameter4)
00074 :RandomVariable(passedTag, RANDOM_VARIABLE_exponential)
00075 {
00076         tag = passedTag ;
00077         lambda = passedParameter1;
00078         startValue = getMean();
00079 }
00080 
00081 
00082 ExponentialRV::~ExponentialRV()
00083 {
00084 }
00085 
00086 
00087 void
00088 ExponentialRV::Print(OPS_Stream &s, int flag)
00089 {
00090 }
00091 
00092 
00093 double
00094 ExponentialRV::getPDFvalue(double rvValue)
00095 {
00096         double result;
00097         if ( 0.0 < rvValue ) {
00098                 result = lambda * exp(-lambda * rvValue);
00099         }
00100         else {
00101                 result = 0.0;
00102         }
00103         return result;
00104 }
00105 
00106 
00107 double
00108 ExponentialRV::getCDFvalue(double rvValue)
00109 {
00110         double result;
00111         if ( 0.0 < rvValue ) {
00112                 result = 1 - exp(-lambda*rvValue);
00113         }
00114         else {
00115                 result = 0.0;
00116         }
00117         return result;
00118 }
00119 
00120 
00121 double
00122 ExponentialRV::getInverseCDFvalue(double probValue)
00123 {
00124         return -log(1.0-probValue)/lambda;
00125 }
00126 
00127 
00128 const char *
00129 ExponentialRV::getType()
00130 {
00131         return "EXPONENTIAL";
00132 }
00133 
00134 
00135 double 
00136 ExponentialRV::getMean()
00137 {
00138         return 1/lambda;
00139 }
00140 
00141 
00142 
00143 double 
00144 ExponentialRV::getStdv()
00145 {
00146         return 1/lambda;
00147 }
00148 
00149 
00150 double 
00151 ExponentialRV::getStartValue()
00152 {
00153         return startValue;
00154 }
00155 
00156 
00157 double ExponentialRV::getParameter1()  {return lambda;}
00158 double ExponentialRV::getParameter2()  {opserr<<"No such parameter in r.v. #"<<tag<<endln; return 0.0;}
00159 double ExponentialRV::getParameter3()  {opserr<<"No such parameter in r.v. #"<<tag<<endln; return 0.0;}
00160 double ExponentialRV::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