0
$\begingroup$

I hope this is not a very complicated question, but I have problems finding the answer. Quite often, I need to calculate something like this: $P(-a<\bar{x}<a) = p$, where $\bar{x}$ refers to the sample mean and p is given. The standard approach is to use the CLT as follows:

$P[(-a-\mu)\sqrt{n}/\sigma) < Z < (a-\mu)\sqrt{n}/\sigma] = p$, where $n, \mu, \sigma$ are given. From here, knowing that Z is distributed $N(0,1)$, we can use "the table" and find the appropriate values for a.

Is there anyway to do it through Mathematica? In particular, I need to find a.

$\endgroup$
2
  • $\begingroup$ Probability[Abs[x] < 1, x \[Distributed] NormalDistribution[]] // N Change the 1 to whatever number you need. $\endgroup$
    – bill s
    Commented Nov 29, 2014 at 19:17
  • $\begingroup$ @bills, I need to find a! $\endgroup$
    – dark blue
    Commented Nov 29, 2014 at 19:19

1 Answer 1

4
$\begingroup$

First, let's find a in functional form:

Probability[Abs[x] < a, x \[Distributed] NormalDistribution[]]

which shows that

f[a_] := Erf[a/Sqrt[2]]

Now you want to solve for the a that has some probability, say 0.1. Then

Solve[f[a] == 0.1, a]

{{a -> 0.125661}}

A little more generally:

Solve[f[a] == p, a]

{{a -> Sqrt[2] InverseErf[p]}}

which provides a direct solution for a with any value of p in terms of the InverseErf function.

$\endgroup$

Your Answer

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

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