There are two problems that should be addressed by this fix
- In certain cases, when sample NDV is very close to sample size, we can end up with negative current NDV estimate, which triggers a tassert. The solution to this is to stop iteration when we can tell we are in this scenario (derivative is very small, or the current guess is about to become negative)
- The NDV assertions in the sampling estimator test are flakey for fields which have many unique values and small sample size. The randomly chosen sample can see a different number of unique values which very much affects the final guess. There are multiple possible solutions to this: relax the assertions, fix the sample seed, etc