Skip to content

Instantly share code, notes, and snippets.

View jukujala's full-sized avatar

Jussi Kujala jukujala

View GitHub Profile
@jukujala
jukujala / fit_lognorm_vs_many_data_distributions.py
Created December 5, 2023 07:42
Generate data from different distributions, fit a log-normal and show how much fitted mean overvaluates data mean.
"""
Generate data from different distributions, fit a log-normal and
show how much fitted mean overvaluates data mean.
Overvaluation 0.05 = 5% higher fitted log-norm mean than data mean.
Copy-paste of output:
* log normal data
- mean(empirical data): 4.22, mean(fitted long-norm): 4.26, overvaluation: 0.01
@jukujala
jukujala / python_blackjack_simulator.py
Last active February 20, 2023 10:09
Blackjack simulator written in Python. API can act as environment for RL agents by passing custom play strategy function to `game(...)`
""" Blackjack simulator, works for RL
* Copied and modified from:
https://gist.github.com/mjhea0/5680216
* See function game(get_player_action) for instructions.
* Requires Python 3.7
* Handles 10M simulations in < 30 mins at Macbook Pro
* Interactive play: python blackjack_simu.py
* Might not implement blackjack rules perfectly
"""
import random
@jukujala
jukujala / moneyh.py
Created May 16, 2018 19:46
calculate annualised return R on financial investment that has returned 11% over 28 monthly investements of $1
import numpy as np
from scipy.optimize import minimize_scalar
def moneyh(R):
""" save 1$ every month for 28 month
Args:
R: annualised yearly interest rate
Returns: