1
$\begingroup$

I was asked to us R or another programming language to the plot $\sum_{j=0}^{k} P(X \geq j)$ where $P(X\geq x) = \frac{1}{1+x} $ as a function of $k.$ What happens when $k$ gets large?

I have no idea how to plot this in R. I'm assuming as $k$ gets large, we get that the probability function goes to 0 since the denominator is increasing?

  • 1
    The sum $\sum_{j=0}^k \frac{1}{j+1}$ is called the $(k+1)$'th [Harmonic number](https://en.wikipedia.org/wiki/Harmonic_number), it grows as $\log(k+1)$ as $k$ gets large.2017-02-16

1 Answers 1

1

Let $Q_k = \sum_{j=0}^k \frac{1}{j+1}= \frac{1}{0+1} + \frac{1}{1+1} + \cdots + \frac{1}{k+1}.$ Then I suppose you are intended to plot $Q_k$ against $k,$ for a few dozen values of $k.$

The proper mathematical answer as to what happens with increasing $k$ is given in the Comment of @Winther, but this seems to be an elementary computational or programming task. I don't see what you are expected to learn about probability from doing this particular exercise, but R can be very useful in a probability course. (At least plotting 100 points shows that $Q_k$ does not go to 0 with increasing $k$.)

Here is sample R code written at the most fundamental level I can manage. (There are more clever ways to program this that take better advantage of the structure of R. Modify as appropriate to your level.)

m = 100;  q = numeric(m)               # m-vector of 0's, change elements within loop
for (k in 1:m) {
  j = 0:k; q[k] = sum(1/(1 + j)) }
plot(q, pch=20, col="blue")            # if 'x' argument missing, plots vs index
curve(.577+log(1+x), col="red", add=T) # per Comment // 'curve' requires 'x' in argument

enter image description here

Table of the first few values:

k = 1:m;  head(cbind(k, q))
     k        q
[1,] 1 1.500000
[2,] 2 1.833333
[3,] 3 2.083333
[4,] 4 2.283333
[5,] 5 2.450000
[6,] 6 2.592857