# Plot cumulative distribution of a function

I want to calculate the probability $P(X\le-0.5)$. I have the probability density function $1/(\pi\sqrt{A^2 - x^2})$. $A$ is supposed to be the square root of noise power, $A = \sqrt{N_0}$, and so changes according to the $N_0$ value given by SNR. The signal power is always $1$, so $\mathrm{SNR} = 1/N_0$. $N_0$ is then $N_0 = 10^{-\mathrm{SNR}(\mathrm{dB})/10}$. I do the following:

1) I write the cumulative distribution function as

$$\int_{-A}^{t} \ \frac{1}{ \pi \sqrt{A^2-x^2}}dx$$

2) Rewrite CDF as

$$\int_{-A}^{t} \ \frac{1}{ \pi A \sqrt{1-(x/A)^2}}dx$$

3) Change variable setting $y=x/A$

4)

$$\int_{-1}^{t/A} \ \frac{1}{ \pi \sqrt{1-(y)^2}}dy$$

Then Mathematica simplifies the equation to

$$\frac{\frac{\pi}{2}+\arcsin( \frac{t}{A} ) }{\pi}$$

with the condition Re[t/A] <= 1 || t/A is not real.

I want to plot the CDF, but $\arcsin$ only gives real values in the range $[-1,1]$ and is complex outside it. So what can I do for the range of $A$ & $N_0$, in order to get the most range of SNR?

• What did you expect? Your probability density is also complex outside $[-A,A]$, so why shouldn't the CDF be? – Lukas Lang Sep 30 '17 at 14:46

f[x_] = 1/(Pi*Sqrt[A^2 - x^2]);


For the PDF to be real

FunctionDomain[f[x], x]

(* A^2 - x^2 > 0 *)


Verifying that f[x] is normalized

Assuming[A > 0, Integrate[f[x], {x, -A, A}]]

(* 1 *)


The distribution is then

dist = ProbabilityDistribution[f[x], {x, -A, A}, Assumptions -> A > 0];

CDF[dist, x] // Simplify Show[
Table[
Plot[Tooltip[CDF[dist, x], A], {x, -5.5, 5.5},
PlotStyle -> ColorData["Rainbow", A/5]],
{A, 1, 5}],
PlotRange -> {{-5, 5}, {0, 1}}] EDIT: Added assumption to FullSimplify to get simpler form

CDF[dist, -1/2] // FullSimplify[#, A > 0] & Plot[%, {A, 1/2, 5}, PlotRange -> {0, 1/2}] Your PDF is actually a special case of the type I Pearson distribution:

pdist = PearsonDistribution[1, -1, 0, -1, 0, A^2];

Refine[PDF[pdist, x], A > 0]


$$\begin{cases}\frac1{\pi\sqrt{\mathtt A-\mathtt x}\sqrt{\mathtt A+\mathtt x}}&-\mathtt A<\mathtt x<\mathtt A\\0&\mathtt{True}\end{cases}$$

Assuming[A > 0, FullSimplify[FunctionExpand[CDF[pdist, x]]]]


$$\begin{cases}1&\mathtt x\geq\mathtt A\\\frac{2\arcsin\sqrt{\frac{\mathtt x}{2\mathtt A}+\frac12}}{\pi }&-1<\frac{\mathtt x}{\mathtt A}<1\\0&\mathtt{True}\end{cases}$$

As it turns out, ArcSinDistribution[] is built-in:

PDF[ArcSinDistribution[{-A, A}], x]


$$\begin{cases}\frac1{\pi\sqrt{\mathtt A-\mathtt x}\sqrt{\mathtt A+\mathtt x}}&-\mathtt A<\mathtt x<\mathtt A\\0&\mathtt{True}\end{cases}$$

CDF[ArcSinDistribution[{-A, A}], x]


$$\begin{cases}\frac{2\arcsin\left(\frac{\sqrt{\frac{a+x}{a}}}{\sqrt{2}}\right)}{\pi}&-a<x<a\\1 & x\geq a\\0&\mathtt{True}\end{cases}$$