Q: A "general definition" of Riemann sum Suppose $f$ is Riemann integerable in $[0,1]$.Prove that $$\lim_{n\rightarrow \infty}\frac{1}{\phi(n)}\sum_{1\leq k\leq n,(k,n)=1}f\left(\frac{k}{n}\right)=\int_0^1f(x)dx$$Here $\phi(n)$ is Euler's function
My attempt: Let $\mu$ be the Möbius function.
$$\begin{align}
LHS-RHS&=\frac{\sum_{k=1}^{n}\sum_{d|(k,n)}\mu(d)f(\frac{k}{n})}{n\sum_{d|n}\frac{\mu(d)}{d}}-\frac{1}{n}\sum_{k=1}^{n}f(\frac{k}{n})\\
&=\frac{1}{n}\frac{\sum_{k=1}^{n}(\sum_{d|(k,n)}\mu(d)-\sum_{d|n}\frac{\mu(d)}{d})f(\frac{k}{n})}{\sum_{d|n}\frac{\mu(d)}{d}}
\end{align}
$$But it seems not to work.Does anyone know how to prove it?Thank you

A: Edit: since this answer was accepted, I'll write out how its previous contents imply the general statement (ie not only continuous functions but Riemann-integrable ones) – that's more or less retelling what was in the comments, in particular Sangchul Lee's.
Let's first show the statement for some special functions, such as $f(x)=e_m(x):=e^{2i\pi mx}$ and $f(x)=x$.
For $f=1$, it's obvious. For $f(x)=x$, it's easy too (use the change of variable $k \rightarrow n-k$ for $n \geq 3$).
Now, if $m$ is an integer and $n \geq 3$, let $g_{m,n}=\sum_k{e_m(k/n)}$ where $k$ runs through the integers between $1$ and $n$ coprime to $n$. Then we can show that $g_{m,n}=\prod_p{g_{ma_p,p}}$, where $p$ runs through the prime powers dividing exactly $n$, and the $a_p$ are integers coprime to $p$ such that $\sum_p{a_p\frac{n}{p}}=1$.
So let $q=p^r$ be a prime power ($p$ prime) and $m$ be an integer. What is $g_{m,q}$? Let $\nu$ be the $p$-adic valuation of $m$. If $\nu \geq r$, then $g_{m,q}=\phi(q)$. If not, then $g_{m,q}=p^{\nu}g_{m/p^{\nu},p^{r-\nu}}$ and this can easily be shown to be zero if $r >\nu+1$ and $-p^{r-1}$ else.
Now, assume that $m \neq 0$ is fixed and $n \rightarrow \infty$. Then $\frac{g_{m,n}}{\phi(n)}=\prod_p{\frac{g_{ma_p,p}}{\phi(p)}}$, where every factor has a modulus of at most $1$.
Let $m_0$ be the product of the prime factors of $m$ and $m_1=|m|m_0$, write $n=n_mn'$ where $n'$ is coprime to $m$ and the prime factors of $n_m$ divide $m$.
Then the above shows (as each $a_p$ is coprime to $p$, working "locally" ie prime per prime) that $\frac{g_{m,n}}{\phi(n)}$ vanishes if $n_m$ does not divide $m_1$, or if $n'$ is not square-free, and that the modulus of this quotient is at most $1/\phi(n')$ if $n'$ is square-free.
It's easy to show then that $g_{m,n}/\phi(n)$ goes to zero.
If $f$ is continuous, then that $f(x)=h(x)+cx$ where $h$ is $1$-periodic (hence a uniform limit of trigonometric polynomials – whose cases are settled) and $c$ is a constant, and it follows easily that the statement holds.
In particular, if $\mu_n$ is the measure on $[0,1]$ given by $\frac{1}{\phi(n)}\sum_k{\delta_{k/n}}$ (where $k$ runs through the integers between $1$ and $n$ coprime to $n$), then $\mu_n$ converges weakly to the Lebesgue measure $\lambda$ on $[0,1]$.
By Portmanteau's theorem, it follows that if $B$ is an interval contained in $[0,1]$, $\mu_n(B)$ goes to the length of $B$. It's easy to see that this means that the statement holds for $1_B$, and thus for every step function.
Assume now that $f$ is Riemann-integrable. Let $\epsilon >0$. This means that there are two step functions $g,h$ with $g \leq f \leq h$ and $\|h-g\|_{L^1} \leq \epsilon$.
Then the limsup of $\int{fd_mu_n}$ is at most the limsup of the integral of $\int{hd\mu_n}$ which is $\int{hd\lambda} \leq \epsilon+\int{gd\lambda} \leq \epsilon+\int{fd\lambda}$.
Similarly, the liminf of $\int{fd\mu_n}$ is at least $\int{fd\lambda}-\epsilon$. Thus $\int{fd\mu_n} \rightarrow \int{fd\lambda}$.

A: Let $(X_n)_{n\geq 1}$ be a sequence of indepenent random variables such that
$$ \mathbf{P}(X_n = k) = \frac{1}{\phi(n)} \quad\text{for each $k$ between $1$ and $n$ coprime to $n$}. $$
In particular, we have
$$ \mathbf{E}[f(X_n)] ​= \frac{1}{\phi(n)} \sum_{\substack{1 \leq k \leq n \\ (k, n) = 1}} f(k/n) $$
for any test functions $f$ on $[0, 1]$. Then we have the following observations:
Step 1. Let $f$ be bounded, measurable, and $1$-periodic. If $(m, n) = 1$, then by the Chinese remainder theorem,
\begin{align*}
\mathbf{E}[f(X_{mn})]
&= \frac{1}{\phi(mn)}\sum_{\substack{1 \leq k \leq mn \\ (k, mn) = 1}} f\left(\frac{k}{mn}\right) \\
&= \frac{1}{\phi(m)\phi(n)} \sum_{\substack{1 \leq j \leq m \\ (j, m) = 1}} \sum_{\substack{1 \leq k \leq n \\ (k, n) = 1}} f\left(\frac{jn + km}{mn}\right)
= \mathbf{E}[f(X_m + X_n)].
\end{align*}
Here, the last line follows from the independence of $X_n$'s.
Step 2. If $n = p^r$ is a prime power, then for any bounded and measurable $f$ on $\mathbb{R}$,
$$ \mathbf{E}[f(X_{p^r})]
= \frac{p}{p-1} \left( \frac{1}{p^r} \sum_{k=1}^{p^r} f(k/p^r) \right) - \frac{1}{p-1} \left( \frac{1}{p^{r-1}} \sum_{k=1}^{p^{r-1}} f(k/p^{r-1}) \right). $$
Now assume in addition $f$ is Lipschitz continuous with the Lipschitz constant $\|f\|_{\text{Lip}}$. Then by the above formula, for each prime power $n = p^r$, we get
\begin{align*}
&\left| \mathbf{E}[f(X_{n})] - \int_{I} f(x) \, \mathrm{d}x \right| \\
&\leq \frac{p}{p-1} \sum_{k=1}^{p^r} \int_{(k-1)/p^r}^{k/p^r} \left| f(k/p^r) - f(x) \right| \, \mathrm{d}x
+ \frac{1}{p-1} \sum_{k=1}^{p^{r-1}} \int_{(k-1)/p^{r-1}}^{k/p^{r-1}} \left| f(k/p^{r-1}) - f(x) \right| \, \mathrm{d}x \\
&\leq \frac{2\|f\|_{\text{Lip}}}{p^{r-1}(p-1)}
\leq \frac{4\|f\|_{\text{Lip}}}{n}.
\end{align*}
Step 3. For each $n$, let $q_n$ denote the largest prime power dividing $n$. Since there are only finitely many $n$'s for which $q_n$ is bounded by each given number, it follows that $q_n \to \infty$ as $n \to \infty$. Write $m_n = n/q_n$ so that $n = q_n m_n$. If $f $ is 1-periodic and Lipschitz continuous, then by the previous steps,
\begin{align*}
\left| \mathbf{E}[f(X_n)] - \int_{0}^{1} f(x) \, \mathrm{d}x \right|
&= \left| \mathbf{E}[f(X_{q_n} + X_{m_n})] - \mathbf{E} \int_{0}^{1} f(x+X_{m_n}) \, \mathrm{d}x \right| \\
&\leq \mathbf{E}\biggl[ \frac{4}{q_n} \| f(\cdot + X_{m_n}) \|_{\text{Lip}} \biggr]
= \frac{4}{q_n} \| f \|_{\text{Lip}}.
\end{align*}
Therefore it follows that $\mathbf{E}[f(X_n)] \to \int_{0}^{1} f(x) \, \mathrm{d}x$.
Step 4. Finally, let $f$ be Riemann integrable on $[0, 1]$. Then for each $\varepsilon > 0$, by modifying the step functions realizing the upper/lower Darboux sums for $f$, we can find 1-periodic and Lipschitz continuous functions $\psi, \varphi$ on $\mathbb{R}$ such that $\psi \leq f \leq \varphi$ on $[0, 1]$ and $\int_{0}^{1} (\varphi(x) - \psi(x)) \, \mathrm{d}x < \varepsilon$. Using this, we get
$$ \limsup_{n\to\infty} \mathbf{E}[f(X_n)]
\leq \limsup_{n\to\infty} \mathbf{E}[\varphi(X_n)]
= \int_{0}^{1} \varphi(x) \, \mathrm{d}x
\leq \int_{0}^{1} f(x) \, \mathrm{d}x + \varepsilon, $$
and similarly
$$ \liminf_{n\to\infty} \mathbf{E}[f(X_n)]
\geq \liminf_{n\to\infty} \mathbf{E}[\psi(X_n)]
= \int_{0}^{1} \psi(x) \, \mathrm{d}x
\geq \int_{0}^{1} f(x) \, \mathrm{d}x - \varepsilon. $$
Letting $\varepsilon \downarrow 0$, the proof is complete.
