Closed jverzani closed 1 year ago
Thank you for making a PR. This looks like a good suggestion. Could you elaborate a bit more on the benefits of bracketing versus non-bracketing intervals? I've read https://docs.juliahub.com/Roots/o0Xsi/1.0.4/roots/, but it's still a bit unclear to me what are the benefits and risks involved in the switch.
This was a case where a bracket helps:
get_n(OneSampleTTest(one_tail); alpha=0.05, es=0.8, power=0.8)
The basic issue is the function used, f(n) = get_alpha(T; n, es, power) - alpha
decays rapidly to an asymptote, so an initial point of 50, far from the zero, has an initial tangent line that pushes the first step of the zero-finding algorithm negative causing issues.
By bracketing you avoid this issue. If the functions are monotone, as this one is, the only drawback to bracketing is the search for a zero is limited to lie within the specified bracket. (A bracketing error will be thrown if not.) I chose some generous ones, but they could be even larger if they don't cover the range of n your users might be looking for.
The underlying algorithm used for bracketing is also used, when possible, by the hybrid method that find_zero
uses when only an initial point is chosen, so performance should be basically identical.
Thanks, John!
This PR uses a bracketing algorithm for
find_zero
, as the initial point approach doesn't seem as robust. I didn't give much thought to the ranges specified and am assuming some monotonicity in the two underlying functions, so bracketing should work as desired.