0

I have a non-decreasing function f such that f is always in [0,1] with f(0)=0 and we know y such that f(y)=1.

I need the most optimal algorithm that finds a set x1,…,xm in [0,y] such that f(xk) is in [(k-1)/(m+1),k/(m+1)].

This should work for any m selected as a hyperparameter, for background this is being used to find percentiles on a very complex CDF.

I thought about using a bisection method for each xi but there must be a more efficient way that incorporates all the information.

Bonus : the function computes such that run{f,(x1,…,xn)} is O(n+1) i.e as n gets large it is asymptotically 2 x faster per element executed than just executing with 1 element. If this can be incorporated then great!

  • If you sample the point in the middle, you know which xi lie to the left and the right of that point, and can recurse appropriately into one or both sides. It seems better than starting the binary search afresh each time. – Paul Hankin Sep 25 '22 at 10:40
  • I think that only helps if you are left with one xi on one side of the midpoint as otherwise you will still need to chop up both sides, am I wrong? – CamalotCoder Sep 26 '22 at 08:42
  • This seems like a good starting point… https://stackoverflow.com/questions/25699858/binary-search-for-multiple-distinct-numbers-in-a-large-array-in-minimum-number-o – CamalotCoder Sep 26 '22 at 09:12
  • Yes, you often have to search on both sides, but you avoid some repeated work compared to doing the binary search for each x_i individually. – Paul Hankin Sep 26 '22 at 09:17

0 Answers0