Skip to content

Instantly share code, notes, and snippets.

View alekfrohlich's full-sized avatar
🎯
Focusing

Alek Frohlich alekfrohlich

🎯
Focusing
View GitHub Profile
@alekfrohlich
alekfrohlich / curves.py
Last active May 3, 2024 12:36
Machine learning experiments of my master's thesis without the dataset.
# Code for plotting predictive value and precision-recall curves along with their associated confidence bands.
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
from xgboost import XGBClassifier
from sklearn.metrics import confusion_matrix
def estimator_bias(m: int, k: int) -> float:
'''Compute bias term appearing in Lemma X.'''
@alekfrohlich
alekfrohlich / gi_arithm.py
Created August 26, 2020 12:38
Gaussian integer multiplication, division, and greates common divisor.
"""Greatest common divisor for gaussian integers."""
def floor(x):
return x // 1
def mult_gi(x, y):
a, b = x
c, d = y
return (a*c - b*d, a*d + b*c)
@alekfrohlich
alekfrohlich / Makedefs.mk
Last active January 15, 2020 02:35
Example Makefile and Makedefs. Features automatic dependency generation and builds out-of-source. The Makefile was written to accommodate C++ source code but it should be easy to adapt it to other compiled languages.
# Application.
APP_NAME := main
# Directories.
ROOT := $(abspath $(dir $(filter %Makedefs, $(MAKEFILE_LIST))))
SRC := $(ROOT)/src
INCLUDE := $(ROOT)/include
BUILD := $(ROOT)/build
# C++ Compiler and Flags.
@alekfrohlich
alekfrohlich / vector_pitfalls.cc
Created December 6, 2019 22:16
vector pitfalls
//file: optm_vec.cc
#include <iostream>
#include <vector>
struct Vertex {
float x, y, z;
Vertex(float x, float y, float z)
: x(x), y(y), z(z)
{
#!/bin/bash
GCC=gcc-7.3.0
BINUTILS=binutils-2.30
echo installing gcc dependencies
sudo apt install -y bison
sudo apt install -y flex
sudo apt install -y libgmp3-dev
sudo apt install -y libmpc-dev
@alekfrohlich
alekfrohlich / Geo.java
Created November 26, 2019 23:51
LLA to ECEF convertion
import static java.lang.Math.*;
public class Geo {
private static final double a = 6378137.0; // WGS-84 semi-major axis
private static final double e2 = 6.6943799901377997e-3; // WGS-84 first eccentricity squared
/**
* Convert Lat, Lon, Altitude to Earth-Centered-Earth-Fixed (ECEF).
* Input is a three element array containing lat, lon (deg) and alt (m).
@alekfrohlich
alekfrohlich / Lexer.java
Last active November 13, 2019 00:10
Simpe scheme-like lexer.
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import static java.lang.Character.*;
// non-reentrant lexer
public class Lexer {
public static enum TokenType {
BEGIN,
@alekfrohlich
alekfrohlich / subfigures.tex
Created November 9, 2019 16:42
Three black boxes
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx,url}
\title{Three black boxes}
\author{alek.frohlich }
\date{November 2019}
\begin{document}