📄 simulate_lognormally_distributed_sequence.cc
字号:
#include <cmath>#include <vector>using namespace std;#include "random.h"vector<double> simulate_lognormally_distributed_sequence(double S, // current value of underlying double r, // interest rate double sigma, // volatitily double time, // time to final date int no_steps){ // number of steps vector<double> prices(no_steps); double delta_t = time/no_steps; double R = (r-0.5*pow(sigma,2))*delta_t; double SD = sigma * sqrt(delta_t); double S_t = S; // initialize at current price for (int i=0; i<no_steps; ++i) { S_t = S_t * exp(R + SD * random_normal()); prices[i]=S_t; }; return prices;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -