Skip to content

Instantly share code, notes, and snippets.

from sympy import simplify, Pow
from sympy.polys import Poly, domains, polyroots
from sympy.assumptions import assuming, ask, Q
import signal
from functools import wraps
# Exceptions #
class GaloisOverflow(Exception):
@javipus
javipus / if_else_comprehension.py
Created August 29, 2018 08:25
List comprehension pitfall in Python 2.7
# Valid
for i in range(1):
for j in range(2) if i else range(1,3):
print(i,j)
# Syntax error :(
[(i,j) for i in range(1) for j in range(2) if i else range(1,3)]
@javipus
javipus / .gitignore
Last active April 14, 2024 14:05
Kullback-Leibler Divergence Estimator.
__pycache__/*
import time
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
"""
Understanding upper bounds for Brier scores through random predictors.
"""
"""
I never cared about my machine's epsilon until I did.
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Machine precision - in bits
prec = -int(np.log2(np.finfo(float).eps))

INTRODUCTION

The goal is to solve two types of probability problems about sampling strings/multi-sets without replacement. The main differences between the two is permutation invariance. One example of each:

  • Problem type # 1: What is the probability of obtaining the sequence 'abb' when picking 3 letters without replacement from {a: 2, b: 3, z: 1}
  • Problem type # 2: What is the probability of picking 1 'd', 1 's' and 3 'g' when picking five letters without replacement from 'gggggggsggdgggg'?

In the naive setting, a transformer is used to map the question to the answer, e.g.

% Prolog translation of the key functions in
% https://github.com/nearai/program_synthesis/blob/master/program_synthesis/algolisp/dataset/code_lisp.py
:- use_module(library(lists)).
:- use_module(library(dicts)).
% if ???
% if(context, cond, then, else).
% get Index-th element in list - alias of nth0 from lists library
@javipus
javipus / address.txt
Created February 8, 2021 10:00
Alfajores celo testnet address
0x995A18F41dcBE5186feFDF8c6aB2852519b9391A
@javipus
javipus / address.txt
Created February 8, 2021 10:23
Alfajores helloworld contract address
0x443140A42AC33de1a38ED9B853B8137542641960
@javipus
javipus / price-manipulation.ipynb
Last active July 31, 2023 07:11
Price oracle manipulation strategies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.