Update project directory structure

This commit is contained in:
David Doebel
2026-03-04 15:01:31 +01:00
parent 04725b27d9
commit 07223a8040
12 changed files with 65 additions and 32 deletions

View File

@@ -1,6 +0,0 @@
//
// Created by David Doebel on 04.03.2026.
//
#include "Analytics.hpp"

View File

@@ -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

View File

@@ -1,10 +1,10 @@
add_library(qengine add_library(qengine
black_scholes.cpp models/black_scholes.cpp
monte_carlo.cpp simulation/monte_carlo.cpp
payoff.cpp models/payoff.cpp
main.cpp main.cpp
Analytics.cpp calibration/Stats.cpp
Analytics.hpp calibration/Stats.hpp
) )
target_include_directories(qengine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(qengine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

29
src/calibration/Stats.cpp Normal file
View 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
View 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

View File

@@ -2,9 +2,9 @@
// Created by David Doebel on 03.03.2026. // Created by David Doebel on 03.03.2026.
// //
#include "black_scholes.hpp" #include "models/black_scholes.hpp"
#include "monte_carlo.hpp" #include "simulation/monte_carlo.hpp"
#include "payoff.hpp" #include "models/payoff.hpp"
#include <iostream> #include <iostream>
int main() { int main() {

View File

@@ -2,4 +2,4 @@
// Created by David Doebel on 03.03.2026. // Created by David Doebel on 03.03.2026.
// //
#include "black_scholes.hpp" #include "black_scholes.hpp"

View File

@@ -2,4 +2,4 @@
// Created by David Doebel on 03.03.2026. // Created by David Doebel on 03.03.2026.
// //
#include "monte_carlo.hpp" #include "monte_carlo.hpp"