Here is yet another finesse (new to me) in getting better performance for some floating-point computation involving the Statistics package.

> restart:

> X:=Statistics:-RandomVariable('Normal'(0,1)):

st:=time():
seq(Statistics:-Quantile(X,1/i,numeric),i=2..10000):
time()-st;[%%][-1];
6.786
-3.719016485

> restart:

> X:=Statistics:-Distribution(Normal(0,1)):

> st:=time():
> seq(X:-QuantileNumeric(1/i),i=2..10000):
> time()-st;[%%][-1];
0.842
-3.71901648545451113

So, look at that. Double precision results in a fraction of the time. That last approach may be avoiding a lot of Library level overhead. Why, heavens, it's almost as fast as the following (which I knew about, though it too is underdocumented),

> restart:

> X:=Statistics:-Distribution(Normal(0,1)):

> G:=Statistics:-MakeProcedure('Quantile',X):

> st:=time():
> seq(G(1/i),i=2..10000):
> time()-st;[%%][-1];
0.734
-3.71901648545451113

acer


Please Wait...