Skip to content

Instantly share code, notes, and snippets.

View LukeMS's full-sized avatar

Lucas de Morais Siqueira LukeMS

View GitHub Profile
@RyanPattison
RyanPattison / alias_table.lua
Last active March 31, 2024 00:31
A Lua implementation of the Alias Method, for sampling from an arbitrary distribution.
local alias_table = {}
function alias_table:new(weights)
local total = 0
for _,v in ipairs(weights) do
assert(v >= 0, "all weights must be non-negative")
total = total + v
end
assert(total > 0, "total weight must be positive")
#! /usr/bin/env python
# tree.py
#
# Written by Doug Dahms
#
# Prints the tree structure for the path specified on the command line
from os import listdir, sep
from os.path import abspath, basename, isdir