QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
kernelfunctions.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 Dimitri Reiswich
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file kernelfunctions.hpp
21 \brief Kernel functions
22*/
23
24#ifndef quantlib_kernel_functions_hpp
25#define quantlib_kernel_functions_hpp
26
28
29namespace QuantLib {
30
31 /*! Kernel function in the statistical sense, e.g. a nonnegative,
32 real-valued function which integrates to one and is symmetric.
33
34 Derived classes will serve as functors.
35 */
37 public:
38 virtual ~KernelFunction() = default;
39 virtual Real operator()(Real x) const = 0;
40 };
41
42
43 //! Gaussian kernel function
45 public:
47 : nd_(average,sigma), cnd_(average,sigma),
48 normFact_(M_SQRT2*M_SQRTPI) {} // normFact is \sqrt{2*\pi}.
49
50 Real operator()(Real x) const override { return nd_(x) * normFact_; }
51
53 return nd_.derivative(x)*normFact_;
54 }
55
57 return cnd_(x)*normFact_;
58 }
59
60 private:
64 };
65
66}
67
68
69#endif
Cumulative normal distribution function.
Gaussian kernel function.
Real derivative(Real x) const
GaussianKernel(Real average, Real sigma)
Real operator()(Real x) const override
Real primitive(Real x) const
NormalDistribution nd_
CumulativeNormalDistribution cnd_
virtual Real operator()(Real x) const =0
virtual ~KernelFunction()=default
Normal distribution function.
QL_REAL Real
real number
Definition: types.hpp:50
Real sigma
#define M_SQRTPI
#define M_SQRT2
Definition: any.hpp:35
normal, cumulative and inverse cumulative distributions