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