Skip to content

Instantly share code, notes, and snippets.

View yoavram's full-sized avatar

Yoav Ram yoavram

View GitHub Profile
@yoavram
yoavram / A3-logaddexp.ipynb
Created May 25, 2020 10:43
A3: logaddexp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yoavram
yoavram / build_tf.sh
Created April 11, 2018 08:21
Build TensorFlow on MacOS as of Dec 21 2017
# https://www.tensorflow.org/install/install_sources
brew install bazel
conda create -n tensorflow python six numpy wheel -y
source activate tensorflow
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./configure
@yoavram
yoavram / betareg.py
Created January 30, 2018 22:11 — forked from brentp/betareg.py
beta regression in statsmodels
# -*- coding: utf-8 -*-
u"""
Beta regression for modeling rates and proportions.
References
----------
Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression
in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in
Economics and Statistics, 2011.
@yoavram
yoavram / Abbreviate Journal Names in Bibtex Database.py
Last active September 25, 2017 06:11 — forked from peci1/Abbreviate Journal Names in Bibtex Database.py
Using the translation table from the Jabref program, finds and replaces all scientific journal names to their standardized abbreviated form. First argument is the file to be processed; outputs safely to 'abbreviated.bib'
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import sys, os
import re
try:
bibtexdb = open(sys.argv[1]).read()
except IndexError:
print("Error: specify the file to be processed!")
@yoavram
yoavram / jeffreys_interval.py
Last active July 27, 2017 15:09
Function to calculate Jefferey's Interval for Binomial proportion confidence interval. See https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Jeffreys_interval
def bin_prop_jeffreys_interval(trials, successes, α=0.05):
"""Binomial proportions confidence Jeffrey's interval.
Parameters
----------
trials : np.ndarray
number of trials
successes : int
number of successes
α : float, 0<α<1
@yoavram
yoavram / Makefile
Last active March 26, 2017 06:00
Makefile to convert Markdown to PDF. Depends on Pandoc 1.19.1, pandoc-citeproc 0.10.4.1, pandoc-crossref 0.2.5.0, Python 3, click 6.6, bibtexparser 0.6.2
main_bib=~/library.bib
ms_bib=bibtex.bib
citation_keys=citation_keys
pdf=ms.pdf
md=ms.md
csl=evolution.csl
diagram_dot = diagram.dot
diagram_pdf = diagram.pdf
@yoavram
yoavram / warn_and_suppress.py
Created February 3, 2017 06:29
A context manager that suppresses exceptions (like contextlib.suppress) and instead evokes warnings. Implementation idea by @alonhorev.
import contextlib
class ExceptionWarning(Warning):
pass
@contextlib.contextmanager
def warn_and_suppress(*exceptions):
try:
yield
except exceptions as e:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yoavram
yoavram / instructions
Created November 22, 2016 07:02
Install and run Python+NumPy using conda on DigitalOcean Ubuntu machines
# if you don't have a digitalocean account, use this link to create an account with $10 free credit: http://m.do.co/c/7a0c04ea8030
# create an Ubuntu droplet: https://cloud.digitalocean.com/droplets/new
# ssh to your new droplet; this is might be the hardest part so don't give up.
# install miniconda 3
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
which python
# if previous command didn't show "/root/miniconda3/bin/python" then run the next command, otherwise skip it
@yoavram
yoavram / regplot.ipynb
Last active September 14, 2016 09:25
Notebook for [seaborn issue 1012](https://github.com/mwaskom/seaborn/issues/1012).
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.