2
$\begingroup$

I observed that there is no Q-function representation in Mathematica. The definition of Q-Function is:

\begin{align} Q(x) &= \frac{1}{\sqrt{2\pi}} \int_x^\infty e^{-\frac{u^2}{2}}du \\ &=\frac{1}{2} \mathrm{erfc}(\frac{x}{\sqrt{2}}) \end{align}

a nother representation of Q-function is: \begin{align} Q(x) = \frac{1}{\pi} \int_0^{\frac{\pi}{2}} e^{\left(\frac{-x^2}{2\sin^2{\phi}} \right)}d\phi \end{align}

there is only Complementary Error Function representation Erfc.

$\mathrm{erfc}(x) = \frac{2}{\sqrt{\pi}} \int_{x}^{\infty} \exp(-t^2) dt$

Is there any possiblity that define a new function in Mathematica? so that it will be a permanent function.

Note: In statistics, the Q-function is the tail probability of the standard normal distribution. In other words, Q(x) is the probability that a normal (Gaussian) random variable will obtain a value larger than x standard deviations above the mean.

$\endgroup$
2
  • 2
    $\begingroup$ How about: q[x_] := Erfc[x/Sqrt[2]]/2; $\endgroup$
    – bill s
    Oct 17, 2013 at 15:05
  • 6
    $\begingroup$ or even q[x_] := SurvivalFunction[NormalDistribution[], x] $\endgroup$
    – chuy
    Oct 17, 2013 at 17:42

2 Answers 2

4
$\begingroup$

There are two parts to your question: how to define the function and how to make it persist between sessions. I suggested

q[x_] := Erfc[x/Sqrt[2]]/2;

though chuy's suggestion looks fine too.To make it persist, you can place this function definition in an initialization cell, and then this will run whenever the notebook is opened. You can find instructions for this here and other information here about running the cell on startup.

$\endgroup$
2
  • $\begingroup$ is it possible in the future versions in Mathematica contain this function? I mean can you tell them or suggest this to them? $\endgroup$
    – sky-light
    Oct 17, 2013 at 23:40
  • 1
    $\begingroup$ I guess you might want to ask Wolfram about that. On the support page wolfram.com/support/contact/email you can email them about bugs or with suggestions. $\endgroup$
    – bill s
    Oct 18, 2013 at 0:06
1
$\begingroup$

If this the function that you use daily, you can put it into you initialization file. Use the command in a notebook:

$UserBasedDirectory

Usually there is a ./Kernel/init.m file. It is evaluated when Mathematica kernel starts. You can put these line in it:

q::usage="q[x] is my Q-function. You cannot modify it, aha!"
q[x_:0] := Erfc[x/Sqrt[2]]/2
Protect[q]

Then you will have several good features:

better def

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.