diff --git a/src/Analytics.cpp b/src/Analytics.cpp deleted file mode 100644 index 74dad10..0000000 --- a/src/Analytics.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// Created by David Doebel on 04.03.2026. -// - -#include "Analytics.hpp" - diff --git a/src/Analytics.hpp b/src/Analytics.hpp deleted file mode 100644 index cee0f98..0000000 --- a/src/Analytics.hpp +++ /dev/null @@ -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 \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d2453c4..cebdde8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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}) diff --git a/src/calibration/Stats.cpp b/src/calibration/Stats.cpp new file mode 100644 index 0000000..1c10315 --- /dev/null +++ b/src/calibration/Stats.cpp @@ -0,0 +1,29 @@ +// +// Created by David Doebel on 04.03.2026. +// + +#include "Stats.hpp" +#include + +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 Stats::CI() const { + return std::make_pair(mean_ - 1.96 * std_error(), mean_ + 1.96 * std_error()); +} diff --git a/src/calibration/Stats.hpp b/src/calibration/Stats.hpp new file mode 100644 index 0000000..8e62d86 --- /dev/null +++ b/src/calibration/Stats.hpp @@ -0,0 +1,26 @@ +// +// Created by David Doebel on 04.03.2026. +// + +#ifndef QUANTENGINE_STATS_HPP +#define QUANTENGINE_STATS_HPP +#include +#include + +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 CI() const; // alpha = 5% + +}; + + +#endif //QUANTENGINE_STATS_HPP \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index cfb565e..8b6df59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 int main() { diff --git a/src/black_scholes.cpp b/src/models/black_scholes.cpp similarity index 63% rename from src/black_scholes.cpp rename to src/models/black_scholes.cpp index 96fe5ac..18efb9c 100644 --- a/src/black_scholes.cpp +++ b/src/models/black_scholes.cpp @@ -2,4 +2,4 @@ // Created by David Doebel on 03.03.2026. // -#include "black_scholes.hpp" \ No newline at end of file +#include "black_scholes.hpp" diff --git a/src/black_scholes.hpp b/src/models/black_scholes.hpp similarity index 100% rename from src/black_scholes.hpp rename to src/models/black_scholes.hpp diff --git a/src/payoff.cpp b/src/models/payoff.cpp similarity index 100% rename from src/payoff.cpp rename to src/models/payoff.cpp diff --git a/src/payoff.hpp b/src/models/payoff.hpp similarity index 100% rename from src/payoff.hpp rename to src/models/payoff.hpp diff --git a/src/monte_carlo.cpp b/src/simulation/monte_carlo.cpp similarity index 64% rename from src/monte_carlo.cpp rename to src/simulation/monte_carlo.cpp index a24d7bd..cfd4ab1 100644 --- a/src/monte_carlo.cpp +++ b/src/simulation/monte_carlo.cpp @@ -2,4 +2,4 @@ // Created by David Doebel on 03.03.2026. // -#include "monte_carlo.hpp" \ No newline at end of file +#include "monte_carlo.hpp" diff --git a/src/monte_carlo.hpp b/src/simulation/monte_carlo.hpp similarity index 100% rename from src/monte_carlo.hpp rename to src/simulation/monte_carlo.hpp