Skip to content

Instantly share code, notes, and snippets.

@stucchio
stucchio / console_output.log
Created February 4, 2020 20:52
Weird doctest errors
File "C:\Users\stucc\Dropbox\src\daywalker\test\..\readme.md", line 86, in readme.md
Failed example:
history[['open', 'high', 'low', 'close', 'volume', 'divCash', 'splitFactor']]
Expected:
open high low close volume divCash splitFactor
date
2004-08-12 17.50 17.58 17.5 17.50 2545100 0.0 1.0
2004-08-13 17.50 17.51 17.5 17.51 593000 0.0 1.0
2004-08-16 17.54 17.54 17.5 17.50 684700 0.0 1.0
Got:
import config
from azure.keyvault.secrets import SecretClient
from azure.identity import ClientSecretCredential
from azure.core.exceptions import ResourceNotFoundError
import time
class AzureKeyVaultConfiguration(config.Configuration):
"""
Configuration class.
@stucchio
stucchio / valuation_of_cash_flow_with_wealth_tax.py
Last active October 20, 2019 01:00
How to compute the valuation of a cash flow in the presence of a wealth tax.
import numpy as np
from numpy.linalg import solve
def vmat(n, discount_rate, tax_rate):
m = np.zeros(shape=(n,n))
discount = tax_rate*np.exp(-1*discount_rate*np.arange(n))
for i in range(n):
m[i, i:n] = discount[0:n-i]
m[i,i] = 1
return m

Keybase proof

I hereby claim:

  • I am stucchio on github.
  • I am stucchio (https://keybase.io/stucchio) on keybase.
  • I have a public key ASA_kgAJceWD7PGBJvFyqObwCMqZDv2hcDqFPpdi8DrJvgo

To claim this, I am signing this object:

from scipy.stats import norm
from numpy import mean
x = norm(0,1).rvs(10000)
y = norm(1,1).rvs(10000) # Group Y is 1 standard deviation better than group X
print("Mean of group X, exceeding the cutoff: " + str(mean(x[x > 3]))) # Prints 3.22
print("Mean of group Y, exceeding the cutoff: " + str(mean(y[y > 3]))) # prints 3.40
from pylab import *
from scipy.stats import uniform, binom, expon, beta
true_gamma = 0.5
N = 600
T = 15
data = zeros((2, N), dtype=float)
event_times = data[0,:]
event_times[:] = uniform(0,15).rvs(N)
from pylab import *
hiv_infections = 29418
gun_homicides = 11078
gun_suicides = 19392
gun_deaths = gun_homicides + gun_suicides
hiv_qualys = array([22.9, 31.9])
hiv_qualys_discounted = array([9.34, 13.18])
@stucchio
stucchio / compass.py
Created January 8, 2016 10:44
Bayesian compass calibration script
from pylab import *
from scipy.stats import norm, uniform
theta_grid = arange(0,2*pi,1.0/1024.0)
true_b = pi/2
b_belief = ones(shape=theta_grid.shape, dtype=float)
b_belief /= b_belief.sum()
import ghalton
from pylab import *
from scipy.stats import gamma
def qmc_gamma(alpha, N):
M = len(alpha)
sequencer = ghalton.Halton(2*M)
valid = ones(shape=(N,), dtype=bool)
hs = array(sequencer.get(N)).transpose()
@stucchio
stucchio / Dockerfile
Created November 4, 2014 14:03
dockerfile for nginx reverse proxy
FROM ubuntu:14.04
MAINTAINER Chris Stucchio <stucchio@gmail.com>
# Nginx
RUN apt-get update && apt-get install -y nginx nginx-extras && mkdir /var/www
ADD nginx.conf /etc/nginx/nginx.conf
ADD run_nginx.sh /bin/run_nginx.sh
RUN chmod +x /bin/run_nginx.sh