Post Reply 
Q function (inverse) and erf(c) inverse in CAS
07-22-2024, 04:52 PM (This post was last modified: 07-22-2024 06:05 PM by nbc12.)
Post: #1
Q function (inverse) and erf(c) inverse in CAS
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
Find all posts by this user
Quote this message in a reply
07-22-2024, 05:50 PM
Post: #2
RE: Q function (inverse) and erf(c) inverse in CAS
(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);
Find all posts by this user
Quote this message in a reply
07-22-2024, 06:06 PM
Post: #3
RE: Q function (inverse) and erf(c) inverse in CAS
(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!
Find all posts by this user
Quote this message in a reply
Post Reply 




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