Skip to content

Instantly share code, notes, and snippets.

View dustinvtran's full-sized avatar

Dustin Tran dustinvtran

View GitHub Profile
TRACE_STACK = [lambda f, *args, **kwargs: f(*args, **kwargs)]
@contextmanager
def trace(tracer):
TRACE_STACK.append(tracer)
yield
TRACE_STACK.pop()
def traceable(func):
def func_wrapped(*args, **kwargs):
@dustinvtran
dustinvtran / main.py
Created December 14, 2020 08:02
Python version of source code for https://mcspeedrun.com/dream.pdf. This implementation uses default precision (float64), so the decimal values are slightly off from the original Java implementation which uses BigDecimal.
import numpy as np
import scipy.stats
from typing import List
def shifty_investigator(num_trials: int,
num_successes: int,
p_success: float):
p_fail = 1. - p_success
target_p = 1. - scipy.stats.binom.cdf(n=num_trials,