HP Forums
Q function (inverse) and erf(c) inverse in CAS - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Q function (inverse) and erf(c) inverse in CAS (/thread-22064.html)



Q function (inverse) and erf(c) inverse in CAS - nbc12 - 07-22-2024 04:52 PM

I'm doing a statistics class this summer, and the CAS on the Prime has been a huge help!

I noticed that the Prime doesn't have these MATLAB functions that we use in class:
qfunc (Q function)
qfuncinv (Inverse Q function)
erfinv (Inverse ERF)
erfcinv (Inverse ERFC)

So I created a CAS program to give me them.

Code:

#cas
QFUNC():=
BEGIN
  erfcinv(x) := normald_icdf(x/2) / -√(2);
  erfinv(x) := erfcinv(1-x);
  qfunc(x) := normald_cdf(-x);
  qfuncinv(x) := -normald_icdf(x);
END;
#end

Feel free to use as you wish. I'm mostly just putting this here so some future stats student can just grab the program.

Maybe these could be included in a future update? It would be helpful to me at least Smile


RE: Q function (inverse) and erf(c) inverse in CAS - Albert Chan - 07-22-2024 05:50 PM

(07-22-2024 04:52 PM)nbc12 Wrote:  erfcinv(x):=normald_icdf((x/2)/-√(2));

Typo. Should be:

erfcinv(x) := normald_icdf(x/2) / -√(2);

Quote:qfunc(x):=(1/2)*erfc(x/√(2))
qfuncinv(x):=(√(2))*erfcinv(2*x)

Nothing wrong with these, but perhaps simpler with cdf / icdf

qfunc(x) := normald_cdf(-x);
qfuncinv(x) := -normald_icdf(x);


RE: Q function (inverse) and erf(c) inverse in CAS - nbc12 - 07-22-2024 06:06 PM

(07-22-2024 05:50 PM)Albert Chan Wrote:  
(07-22-2024 04:52 PM)nbc12 Wrote:  erfcinv(x):=normald_icdf((x/2)/-√(2));

Typo. Should be:

erfcinv(x) := normald_icdf(x/2) / -√(2);

Quote:qfunc(x):=(1/2)*erfc(x/√(2))
qfuncinv(x):=(√(2))*erfcinv(2*x)

Nothing wrong with these, but perhaps simpler with cdf / icdf

qfunc(x) := normald_cdf(-x);
qfuncinv(x) := -normald_icdf(x);

Good catch, I changed the original post to match. And yes, you are right, it is much simpler using cdf and icdf!