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