How can one detect voids in multidimensional (including 1D case) data? By detecting I mean finding the boundaries of them.
A simple example:
import numpy as np
import matplotlib.pyplot as plt
x = np.random.uniform(-1,1,(500,2))
x = x[np.apply_along_axis(lambda t: np.linalg.norm(t) > 0.5, 1, x), :]
plt.scatter(x[:,0], x[:,1])
One simple approach is using histograms.
import numpy as np
import matplotlib.pyplot as plt
x = np.random.uniform(-1,1,(500,2))
x = x[np.apply_along_axis(lambda t: np.linalg.norm(t) > 0.5, 1, x), :]
bins, hist = np.histogramdd(x)
th = 0
axis0_M, axis0_m = hist[0][1:][np.bitwise_or.reduce(bins<=th, axis=1)][0], hist[0][1:][np.bitwise_or.reduce(bins<=th, axis=1)][-1]
axis1_M, axis1_m = hist[1][1:][np.bitwise_or.reduce(bins<=th, axis=0)][0], hist[1][1:][np.bitwise_or.reduce(bins<=th, axis=0)][-1]
plt.vlines(x=[axis0_M, axis0_m], ymin=-x[:, 0].max(), ymax=x[:, 0].max())
plt.hlines(y=[axis1_M, axis1_m], xmin=-x[:, 1].max(), xmax=x[:, 1].max())
plt.scatter(x[:,0], x[:,1])
plt.show()
You can get better results probably by adjusting the bin width of the histogram and playing with different values of the threshold.