Skip to content

Instantly share code, notes, and snippets.

View john-bradshaw's full-sized avatar

John Bradshaw john-bradshaw

View GitHub Profile
@john-bradshaw
john-bradshaw / diff_privacy_functions_hall_demo.py
Created March 9, 2017 01:26
Simple demo for a section in Hall, R., Rinaldo, A. and Wasserman, L., 2013. Differential privacy for functions and functional data. Journal of Machine Learning Research, 14(Feb), pp.703-727.
"""
Code for section 4.1 of:
Hall, R., Rinaldo, A. and Wasserman, L., 2013. Differential privacy for
functions and functional data. Journal of Machine Learning Research, 14(Feb), pp.703-727.
Coded up in a bit of a rush so apologies if there are bugs.
"""
@john-bradshaw
john-bradshaw / numpy_utils_intersect.py
Created April 20, 2016 12:57
intersect_two_numpy_arrays
import numpy as np
def intersect_indcs_two_arrays(x_array, y_array):
"""intersect_indcs_two_arrays(x, y) -> xm, ym
x, y: 1-d arrays of unique values
xm, ym: indices into x and y giving sorted intersection
code taken from http://stackoverflow.com/questions/33529057/indices-that-intersect-and-sort-two-numpy-arrays?lq=1
"""
assert np.all(np.logical_not(map(are_there_duplicates, [x_array, y_array]))), "Intersect assumes arrays are unique."
# basic idea taken from numpy.lib.arraysetops.intersect1d