-
Notifications
You must be signed in to change notification settings - Fork 2
/
Brownian.h
56 lines (46 loc) · 1.47 KB
/
Brownian.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef DEF_BROWNIAN
#define DEF_BROWNIAN
#include <iostream>
#include <string>
#include <random>
#include <armadillo>
/**
* Multi-dimensional brownian motion.
* Simulates the result at the maturity \f$T\f$ of a \f$d\f$-dimensional Brownian motion on \f$\mathbb R^d\f$,
* centered and with correlation matrix \f$\rho\in[-1,1]^{2d}\f$ s.t.
* \f[
* \mathrm d\langle W^i,W^j\rangle_t\ =\ \rho_{i,j}\,\mathrm dt\ ,\qquad\qquad\rho_{i,j}\in[-1,1].
* \f]
*/
class Brownian {
public:
/**
* Constructor of the Brownian motion.
* @param m_dimension by default sets the dimension to 10.
* @param m_maturity by default sets the maturity to one year.
* @param s_correlation the file name that contains the correlation matrix.
*/
Brownian(int m_dimension=10, double m_maturity=1, std::string s_correlation="./data/data_correlation.txt");
/**
* Simulate the vector \f$(W^1_T,\dots,W^d_T)\f$.
*/
arma::vec operator()();
/**
* Simulate the Brownian motion and its opposite. The first column of the matrix is the simulation of \f$(W^1_T,\dots,W^d_T)\f$ and the second
* is \f$(-W^1_T,\dots,-W^d_T)\f$, hence without additional cost. This method is used for the antithetic method of estimation.
*/
arma::mat opposite();
/**
* Return the dimension \f$d\f$ of the Brownian motion.
*/
int getDimension();
/**
* Return the maturity \f$T\f$ of the simulation.
*/
int getMaturity();
private:
int m_dimension;
double m_maturity;
arma::mat m_correlation;
};
#endif