Skip to content

Instantly share code, notes, and snippets.

View Nikolaj-K's full-sized avatar
💭
I'm combinating Why's.

Nikolaj Kuntner Nikolaj-K

💭
I'm combinating Why's.
  • DLR Germany, IST Austria, Infineon, ...
  • Vienna
View GitHub Profile
@Nikolaj-K
Nikolaj-K / logsumexp_vs_max.md
Created January 9, 2026 17:46
Quickie on LogSumExp vs Max

Video where this script is discussed: https://youtu.be/Lsf4eAGvODs

Consider a non-strictly ordered space $X$ with an (absolutely homogenous) absolute value function $|\cdot|: X\to X$ If $B:(X\times X)\to X$ is a symmetric map, then

$B(\max(x, y)-x, \max(x, y)-y) = B(0, |x-y|)$

Proof

@Nikolaj-K
Nikolaj-K / wiki_page_searcher.py
Last active December 31, 2025 19:19
Minimal Wikipedia semantic search wrapper for web integration.
#!/usr/bin/env python3
"""
Minimal Wikipedia semantic search wrapper for web integration.
Install hints (CPU):
- python, duh
- pip install -U sentence-transformers faiss-cpu numpy
Expected index artifacts (see zip):
- path/to/pages_embeddings.index (main data item, 200 MB)
@Nikolaj-K
Nikolaj-K / applied_optimization_2025.md
Last active December 17, 2025 10:19
Applied Optimization 2025, exercises and some eotes

This file starts with Exercises, which ends at exercise 10 and is followed by "Notes: Applied Optimization".

Search for "Exercise 9" for the Regression cost function minimization exercises.

Greetings Nikolaj Kuntner


Exercises - Applied Optimization

@Nikolaj-K
Nikolaj-K / glasser.md
Last active November 21, 2025 18:34
Visualizer for Glasser transform type theorems

Script for the video

https://youtu.be/LfiIiSPg3Ms

$f$ ... Lebesgue-integrable over (all of) ${\mathbb R}$,

$\int_{-\infty}^\infty f\big(x + d\big),{\mathrm d}x = \int_{-\infty}^\infty f\big(x\big),{\mathrm d}x$

$\int_{-\infty}^\infty f\big(x - \dfrac{1}{x}\big),{\mathrm d}x = \int_{-\infty}^\infty f\big(x\big),{\mathrm d}x$

@Nikolaj-K
Nikolaj-K / prob_theory_midterm.md
Last active November 13, 2025 13:15
Probability Theory Statistics Master Midterm

Probability Theory 1 – Script skeleton

  • 2024W-Prob1__script.pdf: sections 1–5 (up to and including 5. Lebesgue-Integral)
  • 2025W-Prob1-Collection.pdf: sections 0–3 (up to and including 3. Das Lebesgue-Integral)

Notes:

  • Warning: I dropped \mathcal, since it doesn't render in gist
  • Likewise, _\# became _H
  • The items have rough importance rankings
  • roughly "important" vs "neutral" and "random"; I'll derank a few later
@Nikolaj-K
Nikolaj-K / appl_opt_251101_ex5.md
Last active November 1, 2025 11:49
Applied Optimization 251101, Ex5

The relevant content starts at page 17 in the script. The chapter ends on page 25. Note that the exercises are different ones from the listing in the script.

==== Exercise's context ====

We consider the general minimization problem $p^{\ast} := \inf_{x \in M \subseteq X} f(x),$ where $X \subseteq \mathbb{R}^n$, $f:X\to\mathbb{R}$ is continuous,

@Nikolaj-K
Nikolaj-K / dependent_bernoulli.py
Created August 31, 2025 21:01
Sampler for two processes with Bernoulli trial marginals
"""
Code and prompt used in the video
https://youtu.be/xcE_0azawvM
"""
"""You'll get two tasks
First part:
Consider a joint distirbution of two random variables X_k with k in {a, b} (i.e. two random variables X_a and X_b),
over a finite outcome sets of size n_a and n_b.
Explain what the marginal distributions are.
@Nikolaj-K
Nikolaj-K / moving_quantily_series.md
Created August 23, 2025 22:56
On capturing probability mass in a shrinking interval

""" Script to the video at https://youtu.be/8w4jHN1LsnY """

===== Moving quantile series ===== === Preliminary - Exponential distribution example === Density: $p_\mu(x) := F'(x) = \frac{1}{\mu} {\mathrm e}^{-\frac{x}{\mu}}$

@Nikolaj-K
Nikolaj-K / geometric_sum_gen_monpmials.tex
Created August 4, 2025 19:33
A generalization of the geometric sum away from using just monomials
"""
Proof prsented in the video
https://youtu.be/Ydyhe7KdRsk
"""
Reminder:
=== Theorem 1, the geometric sum and series formulae ===
$\sum_{k=0}^n a^k = \dfrac{a^{n+1}-1}{a-1}$
@Nikolaj-K
Nikolaj-K / compute_order_statistics.py
Last active July 28, 2025 18:45
Compute the order statistic (by default: for the uniform distribution on [0,1])
"""
Code for the video at
https://youtu.be/CquQe7Y05VA
This script will be easy to generalize, also.
"""
from datetime import datetime
import imageio.v2 as imageio
from io import BytesIO