# Problems calculating and plotting distribution function

After a long time without having touch anything related to maths or statistics, I decided to give myself another chance. I am currently refreshing some concepts of density and distribution functions, and I'm now facing a little misconception. Briefly, I have this density function:

$$\begin{cases} 0 & \text x < 0\\ 2x/(1+x^2 )^2 & \text{x ≥ 0} \end{cases}$$

from which I have obtained the following distribution function after calculating the integrate:

$$\begin{cases} 0 & \text x < 0\\ -1/(1+x)^2 & \text{x ≥ 0} \end{cases}$$

My problem is that I'm trying to plot the distribution function using R, but since the distribution function is negative, I'm not sure if it is correct (shouldn´t it be positive?) and which would be the best way to plot it (of course, I'm a R newby too).

• You quote the indefinite integral, which is defined only up to an additive constant. For the definite integral you are trying to obtain, choose that constant appropriately.
– whuber
Commented Mar 31, 2019 at 16:21

You've a typo in the denominator of your distribution function: $$x$$ should be $$x^2$$, w/o the square of the parentheses. And, as @whuber said, you need a constant term after the integration (for $$x\geq 0$$):
$$F(x)=\int \frac{2xdx}{(1+x^2)^2}=-\frac{1}{1+x^2}+C$$
By definition, $$\lim_{x\rightarrow \infty}F(x)=1$$, substituting yields $$\lim_{x\rightarrow\infty}F(x)=C-\lim_{x\rightarrow\infty}\frac{1}{1+x^2}=C=1$$
So, you can plot the following, for $$x\geq 0$$, (for $$x<0$$, $$F(x)=0$$): $$F(x)=1-\frac{1}{1+x^2}=\frac{x^2}{1+x^2}$$
• Yes, $F(x)$ is CDF and is actually defined as $P(X\leq x)=\int_{-\infty}^x f(x)$. You cannot sum individual $f$'s because $x$ is continuous. What about $f(1.5),f(1.55),f(1.553),...$, Commented Mar 31, 2019 at 18:37