Post Reply 
[WP34s] A set of new quantile functions
06-02-2014, 08:32 PM
Post: #12
RE: [WP34s] A set of new quantile functions
It's me again. Here is the third reply to my own post. #-)

(06-01-2014 01:18 PM)Dieter Wrote:  
(05-30-2014 06:13 AM)Dieter Wrote:  Recent tests showed that a similar behaviour may also occur with the Student quantile function.
(...)
I will take a closer look at this and see if an approach similar to the Chi² case will eliminate this.

It does. Here is an improved version of the Student quantile function that uses the same approach as the Chi² quantile: it solves ln(cdf/p) = 0.
...
If the new code is too long and/or uses too much memory, the iteration limit in R01 may be removed.

Final update: there is another solution. The original (shorter) TQF version can be used with a slight modification.

The program uses two different estimates. One for the central region and another for p close to 0 or 1. At least one of these seems to be good enough to ensure reasonably fast convergence. But in some cases, especially for very high dof values, choosing the one or the other is quite tricky since there is just a narrow corridor of probabilities where both approximations work equally well. So the crucial point is the decision whether to use the central or the tail estimate.

Up to now this was done by checking whether the input is greater or less than 12–n. This mostly works well, but it is not sufficiently exact for a few critical cases. After some tests I can suggest a different threshold that seems to work fine: simply replace the constant 12 with the term sqrt(n) + 7,5.

So these lines near the beginning of TQF...

Code:
...
# 012
RCL J
+/-
y[^x]
...

...are replaced with these:

Code:
...
RCL J
[sqrt]
# 075
SDR 001
+
RCL J
+/-
y[^x]
...

And that's it.

So there are essentially two ways of solving the problem of slow convergence in some extreme cases:

1. The safe method: use a robust algorithm. This is the approach of the second version I posted, i.e. solving ln(cdf/p) = 0. However, this requires more code and memory.

2. Since the initial estimates are good enough, the threshold for switching between the two may be fine-tuned. With the suggested fix the original shorter version of TQF should work fine. I could not find a case where more than four iterations were required.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [WP34s] A set of new quantile functions - Dieter - 06-02-2014 08:32 PM



User(s) browsing this thread: 1 Guest(s)