Skip to content

Instantly share code, notes, and snippets.

View austinschneider's full-sized avatar

Austin Schneider austinschneider

View GitHub Profile
@austinschneider
austinschneider / fc.py
Last active April 30, 2021 18:07
Computes Feldman & Cousins style intervals for the mean of a bin, assuming Poisson distributed observations and no inter-bin correlations or external information.
# Feldman Cousin's interval
# Author: Austin Schneider (https://github.com/austinschneider)
import numpy as np
from scipy.stats import poisson
import collections
from functools import wraps
class memodict_(collections.OrderedDict):
def __init__(self, f, maxsize=1):
@austinschneider
austinschneider / slurm_queue_limit_submit.py
Last active May 27, 2022 20:04
Slurm submission script for systems that limit the number of queued jobs
import glob
import time
import numpy as np
import subprocess
def slurm_get_n_jobs(user):
command = f"squeue --user {user} --array --format=%all"
result = subprocess.run(command.split(" "), stdout=subprocess.PIPE)
lines = result.stdout.split(b"\n")
@austinschneider
austinschneider / fd_tree_pseudocode.cpp
Created June 2, 2022 20:24
How to (roughly) build a KDTree for mesh-ray intersection calculations
// https://en.wikipedia.org/wiki/K-d_tree
// On building fast kd-Trees for Ray Tracing, and on doing that in O(N log N)
// http://www.irisa.fr/prive/kadi/Sujets_CTR/kadi/Kadi_sujet2_article_Kdtree.pdf
// https://axom.readthedocs.io/en/develop/index.html#
// https://web.archive.org/web/20090803054252/http://tog.acm.org/resources/GraphicsGems/gems/RayBox.c
#include <math.h>
#include <memory>
#include <vector>