Using random numbers to evaluate $\sum_{k=1}^{10000}e^{\frac{k}{10000}}$ I tried using the Monte Carlo Method to approximate the sum $\sum_{1}^{10000}e^{\frac{k}{10000}}$.  First I genarating 100 random numbers in (1, 10000). Then by the strong law of large numbers:
$$\sum_{i=1}^{100}\frac{f(U_i)}{k} \to E[f(U)] = \theta$$
where:
$$\theta = \int_{1}^{10000}e^{\frac{x}{10000}}dx$$
The exercise says to use only 100 random numbers. So dont know if that thought is right, because this method requires k→∞
 A: You are confusing a few different concepts:


*

*You write $\frac{1}{k}\sum_{i=1}^{100}f(U_i)\to\mathbb{E}[f(U)]$ when you clearly mean $\frac{1}{100}\sum_{i=1}^{100}f(U_i)\approx\mathbb{E}[f(U)]$.

*You talk about random numbers in $\{1,\dots,10000\}$ (implying that you choose them uniformly). This is therefore a discrete random variable. To evaluate its expectation, you then integrate between 1 and 10000 as if it were continuous (and you don't even normalize the density).


Let us go back to the basics. You know that for any continuous function $f$ on $[0,1]$, 
$$\frac{1}{N}\sum_{k=0}^Nf\left(\frac{k}{N}\right)\xrightarrow[N\to+\infty]{}\int_0^1f(x)\,\mathrm{d}x.$$
By identification, do you see what function $f$ you should choose to approximate $\sum_{k=1}^{10000}e^{k/1000}$?
Let us assume that you have found such an $f$, and $\sum_{k=1}^{10000}e^{k/1000}\approx\int_0^1f(x)\,\mathrm{d}x$. You may write 
$$\int_0^1f(x)\,\mathrm{d}x=\mathbb{E}[f(U)],$$
where $U$ is a uniform random variable on $[0,1]$. Then, do you see how to approximate $\mathbb{E}[f(U)]$ by using the Monte Carlo techniques you mention in your post?
A: This looks slightly messy to me, in that we are mixing to different approximations: an integral that is (numerically) approximated by a sum, and a integral (or a sum) that is (probabilistically) approximated by a Montecarlo extraction.
There is no need to convert the integral to a (approximate) sum to evaluate it via Montecarlo - and might be confusing to suggest that.
Let's say we want to evaluate
$$I=\int_0^1 e^x dx $$
On one hand, this can be approximated by a finite sum:
$$I= \frac{1}{10000}\int_0^{10000} e^{t/10000}dt\approx \frac{1}{10000} \sum_k e^{k/10000}$$
On the other (rather unrelated) hand, the integral can be evaluated via Montecarlo. Let $Y$ be a random variable uniform in $[0,1]$ Then , letting $u(y)=e^{y}$
$$E[u(Y)]=\int_{0}^1 f_Y(y)\, u(Y) dY = I$$
Then, we can evaluate the integral as an expectation, and so we can throw a large number (say $N=100$) of values of $Y$ and approximate
$$I =E(u(Y)) \approx \frac{1}{N}\sum_{i=1}^N u(Y_i) $$
Notice that this $N$ has no relation with the $10000$ above. To evaluate if this $N$ is big enough, we could try to compute the variance. Anyway, informally, if the variable is not "tricky" (if the densitiy does not varies wildly in the support), 100 (even sometimes 30) is considered a reasonable number for using the law of large numbers.
