123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include <iostream>
- #include <math.h>
- #include "LHCumulativeGauss.h"
- using namespace OBJREC;
- using namespace std;
- static const double sqrt2pi = sqrt(2*M_PI);
- LHCumulativeGauss::LHCumulativeGauss( double _lengthScale, double _bias )
- {
- lengthScale = _lengthScale;
- bias = _bias;
- }
- double LHCumulativeGauss::stdNormPDF (double x)
- {
- return exp(-x*x)/sqrt(M_PI);
- }
- double LHCumulativeGauss::thirdgrad ( double y, double f ) const
- {
-
- double gradient = this->gradient(y,f);
- double hessian = this->hessian(y,f);
- return -2* ( hessian*lengthScale*(f*lengthScale+bias) + gradient * lengthScale * lengthScale
- + hessian * gradient );
- }
- double LHCumulativeGauss::hessian ( double y, double f ) const
- {
-
- double gradient = this->gradient(y,f);
- return ( -2*(f*lengthScale + bias)*lengthScale*gradient - gradient*gradient );
- }
- double LHCumulativeGauss::gradient ( double y, double f ) const
- {
-
- return ( y*lengthScale*stdNormPDF(f*lengthScale + bias)/likelihood(y,f) );
- }
- double LHCumulativeGauss::logLike ( double y, double f ) const
- {
- return log ( likelihood(y, f) );
- }
- double LHCumulativeGauss::likelihood ( double y, double f ) const
- {
-
- return ( ::erf(y*(f*lengthScale + bias))+1 ) / 2.0;
- }
- double LHCumulativeGauss::predictAnalytically ( double fmean, double fvariance ) const
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- double lssqr = lengthScale * lengthScale;
-
- return likelihood( 1.0, (fmean + bias/lengthScale) / sqrt(1.0 + 2.0 * fvariance * lssqr) - bias/lengthScale );
- }
|