Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Grivas andreasgrv

View GitHub Profile
@andreasgrv
andreasgrv / zonotope-hyperplane-intersection.ipynb
Last active Mar 25, 2022
Visualisation of zonotope / hyperplane intersection
View zonotope-hyperplane-intersection.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andreasgrv
andreasgrv / out.txt
Last active Nov 28, 2017
Approximation of samples from a normal by summing samples of uniform.How close to the max value of the Box Muller transform (https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform clamp at 6.66 standard deviations when using float32) can we get when using a sum of iid uniform samples ?
View out.txt
Got absmax : 2.6663 after 100 iters and 0.00 secs
Got absmax : 2.8621 after 200 iters and 0.00 secs
Got absmax : 3.0409 after 600 iters and 0.00 secs
Got absmax : 3.3918 after 700 iters and 0.00 secs
Got absmax : 3.3950 after 1000 iters and 0.00 secs
Got absmax : 3.6232 after 1100 iters and 0.00 secs
Got absmax : 3.7237 after 2900 iters and 0.01 secs
Got absmax : 3.8769 after 4200 iters and 0.01 secs
Got absmax : 4.0837 after 13400 iters and 0.04 secs
Got absmax : 4.1979 after 71500 iters and 0.17 secs
@andreasgrv
andreasgrv / dotpath.py
Created May 13, 2016
Python metaclass experimentation (python 2.7) applied on creating paths
View dotpath.py
""" experiment on whether we can make a more intuitive interface
for paths by (ab)using metaclasses :D
result :
s = DotPath.myfolder
versus:
s = os.path.join('home','user','myfolder')"""
import os
import codecs
@andreasgrv
andreasgrv / command_version.sh
Created Nov 19, 2015
Check which flag is used more to get the version of the command ( -version or --version ). Began this after being totally annoyed that java --version doesn't work.
View command_version.sh
#!/bin/bash
total_commands=0
count_one_dash=0
count_two_dash=0
commands_only_one_dash=0
for command in bash gcc java python perl gunzip unzip less cat vi nano pico ls who find locate rm cp
do
((total_commands++))
eval "$command -version" > /dev/null 2>&1
ret_code=$?
@andreasgrv
andreasgrv / Makefile
Last active Jul 7, 2019
An example of python boost use for a python - C++ interface utilizing python lists as arguments
View Makefile
drow.so:
g++ -Wall -shared -fPIC -o drow.so drow.cpp -std=c++0x -lboost_python -I/usr/include/python2.7
View dataset.py
""" module for dataset stuff """
import pandas as pd
def text_counts(filename, label_col):
"""Get counts for how many texts there are for each type of author
:labels: The different classes the data belongs to
:returns: list of numbers of counts
"""
View exception_game
exception_game
==============
How 'not' to use exception handling.
Well since C++ unlike Java actually lets the programmer figure out how he wants to use exceptions..
Why not exploit the exceptions mechanism and be a bit more creative!?