Skip to content

Instantly share code, notes, and snippets.

View JSzitas's full-sized avatar

Juraj Szitás JSzitas

  • Barclays
  • Prague
View GitHub Profile
@JSzitas
JSzitas / .cpp
Last active April 20, 2023 12:24
Count how many people are alive per year, based on their birthyear and deathyear
#include <chrono>
#include <iostream>
#include <vector>
constexpr size_t kPeople = 10000;
constexpr size_t kLowBoundAge = 1;
constexpr size_t kHighBoundAge = 100;
constexpr size_t kAgeLen = kHighBoundAge - kLowBoundAge;
int main()
@JSzitas
JSzitas / beatdown.cpp
Created March 19, 2024 00:29
'I will pin your comment if you can optimize this' - about 2 hours later....
#include <array>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>
void generate_array(std::vector<int>& arr, std::mt19937& gen) {
std::uniform_int_distribution<> dis(0, 99);
for (int & i : arr) {
i = dis(gen);
@JSzitas
JSzitas / ou_testing.R
Created March 24, 2024 08:27
Description of multiple testing problems with many random processes
# discretised ornstein-uhlenbeck
ou <- function(steps, theta = 1.0, mu = 1.2, sigma = 0.3, dt = 0.01) {
x <- rep(NA, steps+1)
x[1] = 0
for(i in 2:(steps+1)) {
x[i] = x[i-1] + theta * (mu - x[i-1]) * dt + sigma * sqrt(dt) * rnorm(1);
}
return(x)
}
# ~~2 years of simulated data if you account for weekends and holidays