Skip to content

Instantly share code, notes, and snippets.

View andyljones's full-sized avatar
🤖
👩👨👩👨

Andy Jones andyljones

🤖
👩👨👩👨
View GitHub Profile
@andyljones
andyljones / readme.md
Last active March 7, 2021 09:43
copyright with perfect attribution

Setup

  • Suppose you had a black box that could attribute a new idea to a bundle of old ideas, and identify the novel contribution.
  • Can we use this to set up a system where authors get paid based on anything that ever depends on their novel contribution?

Selling an idea

  • I'm an author. I've taken some other people's ideas, mixed them together, and come up with something new.
  • I announce to the world that I have had a new idea. I can't publish the idea openly, because then no-one'd pay me for it! Instead I publish some tags describing the idea so that potential purchasers can come talk to me.
  • A potential purchaser shows up. They send me a gogol* of themselves, a little AI approximation of them.
  • I put the purchaser's gogol in a sandbox with my idea. It evaluates the idea and proposes a price. The sandbox is then destroyed.
  • If I'm happy with the price, I send the purchaser the idea and they send me the cash. This transaction is public.
@andyljones
andyljones / vaccinated_ifrs.py
Created February 13, 2021 15:36
A naive estimate in the reduction in IFR you get from vaccinating the most vulnerable fraction of the population
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from io import StringIO
import matplotlib.ticker as mtick
# Source: p11, https://www.imperial.ac.uk/media/imperial-college/medicine/mrc-gida/2020-10-29-COVID19-Report-34.pdf
IFR = """
0-4 0.00 (0.00, 0.03) 0.00 (0.00, 0.03)
5-9 0.01 (0.00, 0.06) 0.01 (0.00, 0.06)
@andyljones
andyljones / mcts_tests.py
Created December 13, 2020 12:26
example mcts tests
import torch
import torch.testing
import torch.distributions
import pytest
from . import cuda
from rebar import arrdict
import aljpy
### ROOT TESTS
@andyljones
andyljones / Xorg.0.log
Last active August 8, 2020 07:01
healthy coolgpus logs
[ 53628.957]
X.Org X Server 1.20.8
X Protocol Version 11, Revision 0
[ 53628.957] Build Operating System: Linux 4.4.0-184-generic x86_64 Ubuntu
[ 53628.957] Current Operating System: Linux aj-server 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64
[ 53628.957] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-42-generic root=UUID=c089030c-4cd8-41c8-bddd-6545a222aa6f ro quiet splash vt.handoff=7
[ 53628.957] Build Date: 24 June 2020 06:00:21AM
[ 53628.957] xorg-server 2:1.20.8-2ubuntu2.2 (For technical support please see http://www.ubuntu.com/support)
[ 53628.957] Current version of pixman: 0.38.4
[ 53628.957] Before reporting problems, check http://wiki.x.org
@andyljones
andyljones / bokeh_td.py
Created May 14, 2020 14:37
Bokeh timedelta axis formatting, showing just the parts of 00h00m00s necessary.
def timedelta_xaxis(f):
"""Expects the axis to be in millis"""
f.xaxis.ticker = bom.tickers.DatetimeTicker()
f.xaxis.formatter = bom.FuncTickFormatter(code="""
// TODO: Add support for millis
// Calculate the hours, mins and seconds
var s = Math.floor(tick / 1e3);
var m = Math.floor(s/60);
@andyljones
andyljones / ngo_restriction.py
Last active February 13, 2020 17:06
Exemplar plot for comparing pairs of discrete distributions
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
def raw_data():
restriction = ['not', 'slightly', 'moderately', 'very']
gov = pd.DataFrame({
'democracy': [.6, .2, .1, .1],
'autocracy': [.2, .3, .5, .4]}, index=restriction)
@andyljones
andyljones / mpshang.py
Last active October 28, 2022 09:28
Demonstration of the MPS hang bug
"""This script should be run on a machine with at least 2 GPUs and an MPS server running. You can launch an MPS daemon with
```
nvidia-cuda-mps-control -d
```
The script first uses `test_cuda` to verify a CUDA context can be created on each GPU. It then spawns two workers; a
'good' worker and a 'bad' worker. The workers collaborate through Pytorch's DataDistributedParallel module to calculate
the gradient for a trivial computation. The 'good' worker carries out both the forward and backward pass, while the
bad worker carries out the forward pass and then exits. This seems to lock up the MPS server, and any subsequent
attempts to create CUDA contexts fail by hanging eternally.
"""
This is a standalone script for demonstrating some memory leaks that're troubling me. It's a torn-down version of
the project I'm currently working on.
To run this, you'll need panda3d, pandas and tqdm. You should be able to install these with
```
pip install panda3d pandas tqdm
```
You'll **also need to enable memory tracking**. Do that by setting `track-memory-usage 1` in `panda3d.__file__`'s
`etc/Config.prc` file. Setting it anywhere else is too late! (It's a unique setting in that way - thanks rdb!)
@andyljones
andyljones / temperature.py
Last active August 26, 2018 18:23
Demonstrates the importance of perceptually uniform colormaps using temperature in Central England over the past 200 years
import requests
import pandas as pd
from io import BytesIO
import matplotlib as mpl
import matplotlib.pyplot as plt
url = 'https://www.metoffice.gov.uk/hadobs/hadcet/cetdl1772on.dat'
raw = pd.read_csv(BytesIO(requests.get(url).content), sep='\s+', header=None)
raw.columns = ['year', 'day'] + list(range(1, 13))
@andyljones
andyljones / bankruptcy.py
Last active February 5, 2017 16:46
Simple script for estimating bankruptcy probabilities during retirement
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 5 11:01:52 2017
@author: andyjones
"""
import scipy as sp
import matplotlib.pyplot as plt