Update project directory structure
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
//
|
||||
// Created by David Doebel on 04.03.2026.
|
||||
//
|
||||
|
||||
#include "Analytics.hpp"
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
//
|
||||
// Created by David Doebel on 04.03.2026.
|
||||
//
|
||||
|
||||
#ifndef QUANTENGINE_ANALYTICS_HPP
|
||||
#define QUANTENGINE_ANALYTICS_HPP
|
||||
|
||||
class Analytics {
|
||||
public:
|
||||
Analytics() = delete;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //QUANTENGINE_ANALYTICS_HPP
|
||||
@@ -1,10 +1,10 @@
|
||||
add_library(qengine
|
||||
black_scholes.cpp
|
||||
monte_carlo.cpp
|
||||
payoff.cpp
|
||||
models/black_scholes.cpp
|
||||
simulation/monte_carlo.cpp
|
||||
models/payoff.cpp
|
||||
main.cpp
|
||||
Analytics.cpp
|
||||
Analytics.hpp
|
||||
calibration/Stats.cpp
|
||||
calibration/Stats.hpp
|
||||
)
|
||||
|
||||
target_include_directories(qengine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
29
src/calibration/Stats.cpp
Normal file
29
src/calibration/Stats.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by David Doebel on 04.03.2026.
|
||||
//
|
||||
|
||||
#include "Stats.hpp"
|
||||
#include <cmath>
|
||||
|
||||
void Stats::update(double x) {
|
||||
// update the mean according to the formula
|
||||
// \hat{a}_n \cdot \frac{n}{n+1} + \frac{a_{n+1}}{n+1}
|
||||
double n_ratio = n_ / ++n_ ;
|
||||
mean_ = n_ratio * mean_ + x/n_;
|
||||
// update the second moment
|
||||
M2 = n_ratio * M2 + x * x / n_;
|
||||
// update the
|
||||
|
||||
}
|
||||
|
||||
double Stats::variance() const {
|
||||
return M2 - mean_ * mean_;
|
||||
}
|
||||
|
||||
double Stats::std_error() const {
|
||||
return std::sqrt(variance()/n_);
|
||||
}
|
||||
|
||||
std::pair<double, double> Stats::CI() const {
|
||||
return std::make_pair(mean_ - 1.96 * std_error(), mean_ + 1.96 * std_error());
|
||||
}
|
||||
26
src/calibration/Stats.hpp
Normal file
26
src/calibration/Stats.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by David Doebel on 04.03.2026.
|
||||
//
|
||||
|
||||
#ifndef QUANTENGINE_STATS_HPP
|
||||
#define QUANTENGINE_STATS_HPP
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
class Stats {
|
||||
private:
|
||||
size_t n_ = 0;
|
||||
double mean_ = 0.0;
|
||||
double M2 = 0.0;
|
||||
|
||||
public:
|
||||
Stats() = delete;
|
||||
void update(double x);
|
||||
double variance() const;
|
||||
double std_error() const;
|
||||
std::pair<double, double> CI() const; // alpha = 5%
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //QUANTENGINE_STATS_HPP
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by David Doebel on 03.03.2026.
|
||||
//
|
||||
|
||||
#include "black_scholes.hpp"
|
||||
#include "monte_carlo.hpp"
|
||||
#include "payoff.hpp"
|
||||
#include "models/black_scholes.hpp"
|
||||
#include "simulation/monte_carlo.hpp"
|
||||
#include "models/payoff.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
|
||||
Reference in New Issue
Block a user