This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder