Why does plot(ecdf(1:1000)) produce a straight line?

Since Fn($x_n$) = $x_1$/(total sum) +$x_2$/(total sum) +…+$x_n$/total sum = ($x_1+x_2+x_3+…+x_n$)/total sum.

the fact that Fn(200) roughly being equal to 0.2 and sum(0:200) roughly being equal to 0.4 seems to indicate that sum(1:200) is roughly half of sum(1:400), which isn't true, the two expressions being 20,000 and 80,000 respectively.

What am i misunderstanding?

**Contents**hide

#### Best Answer

The cumulative distribution function of a random variable $X$ has nothing to do with *summing* the random variable. It is

the probability that $X$ will take a value less than or equal to $x$.

And of course, the probability that a value randomly sampled from your vector $(1, dots, 1000)$ is less than or equal to 200 is exactly half the probability that it is less than or equal to 400.